using System.Collections;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows.Forms;
using System.Data.OleDb;
//using System.Data.OleDb.OleDbCommandBuilder;//JMR -- DEV -- commented out


namespace ePlanSysOman
{
    public partial class frmHarness
    {
        public static OleDbDataAdapter daPTP2 = new OleDbDataAdapter();
        public static OleDbDataAdapter daCBE2 = new OleDbDataAdapter();
        public static DataSet dsql = new DataSet();//JMR
        DataSet dsql2 = new DataSet();//JMR
        public static clsData dcl = new clsData();//JMR
        Thread updatethread;

        //JMR
        Object UpdateThreadStartPTP1 = new ThreadStart(QueryDataBase);//JMR look at          taking away 'this.' and making the function static fixes this
        Object UpdateThreadStartPTP2 = new ThreadStart(QueryDataBase2);
        Object UpdateThreadStartCBE1 = new ThreadStart(QueryDataBase3);
        Object UpdateThreadStartCBE2 = new ThreadStart(QueryDataBase4);
        Object UpdateThreadStartWires = new ThreadStart(MakeWires);

        //   Dim CallDataBindToDataGrid = New MethodInvoker(Me, DirectCast(Me.DataBindToDataGrid, IntPtr))
        bool FormCloseex2 = true;//JMR
        private void grdHarnSel_DoubleClick(object sender, EventArgs e)
        {
            DataSet aset = new DataSet();
            clsData data = new clsData();
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            if (!(Module1.newModule.ISRUNN | Module1.newModule.makewiresb))
            {
                string plnumber;
                if (Module1.newModule.BAckhrn)
                {
                    plnumber = Module1.newModule.plnumber;
                }
                else
                {
                    plnumber = Module1.newModule.plnumber;
                }
                Module1.newModule.HARNESSID = Guid.NewGuid().ToString();
                if (!Module1.newModule.oldSel)
                {
                    Module1.newModule.oldSel = true;
                    Module1.newModule.OldHarnessPTP = Conversions.ToString(viewHarnSel.GetRowCellValue(this.viewHarnSel.GetSelectedRows()[0], "PART_NUMBER"));//JMR Converted to string 
                    Module1.newModule.OldDRW = Conversions.ToString(viewHarnSel.GetRowCellValue(this.viewHarnSel.GetSelectedRows()[0], "DWG"));//JMR Converted to string
                    txtOldHarnessPTP.Text = Module1.newModule.OldHarnessPTP;//JMR
                    Module1.newModule.oldharn = Module1.newModule.OldHarnessPTP;
                    MessageBox.Show(" Old Harness selected." + thirteen + ten + "Select now new Harness.", "Select Harness", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);//JMR
                }
                else
                {
                    Module1.newModule.NewHarnessPTP = Conversions.ToString(viewHarnSel.GetRowCellValue(viewHarnSel.GetSelectedRows()[0], "PART_NUMBER"));//JMR converted to string
                    Module1.newModule.newharn = Module1.newModule.NewHarnessPTP;
                    Module1.newModule.NewDWG = Conversions.ToString(this.viewHarnSel.GetRowCellValue(this.viewHarnSel.GetSelectedRows()[0], "DWG"));//JMR converted to string
                    txtNewHarnesPTP.Text = Module1.newModule.NewHarnessPTP;
                    if ((Module1.newModule.OldDRW == Module1.newModule.NewDWG))
                    {
                        DialogResult result;
                        if ((Module1.newModule.OldHarnessPTP == Module1.newModule.NewHarnessPTP))
                        {
                            Module1.newModule.OldHarnessPTP = (Module1.newModule.NewHarnessPTP + "99");
                            Module1.newModule.oldharn = Module1.newModule.OldHarnessPTP;//neither of these variables had Module1.newModule or Module1 class attached to it
                            result = MessageBox.Show(("Do you want to create new harness " + Module1.newModule.NewHarnessPTP + " ."), "Confirm selection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);//JMR
                        }
                        else
                        {
                            result = MessageBox.Show(("You select " + Module1.newModule.OldHarnessPTP + " to be reworked to " + Module1.newModule.NewHarnessPTP), "Confirm selection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        }
                        if ((result == DialogResult.Yes))
                        {
                            string str2;
                            clsData data2 = new clsData();
                            Module1.newModule.oldSel = false;
                            Application.DoEvents();
                            try
                            {
                                data.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN ='-' WHERE WIRE_END_PIN IS NULL ");
                                data.ExecuteSQL("UPDATE PTP SET WIRE_END_PN ='-' WHERE WIRE_END_PN IS NULL ");
                            }
                            catch (Exception exception1)
                            {

                                Exception exception = exception1;

                            }
                            if (Module1.newModule.BAckhrn)
                            {
                                data.ExecuteSQL(("DELETE * FROM PDFWIRE1 WHERE pdfplid1 = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM PDFWIRE2 WHERE pdfplid2 = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLBACKSHOPWIRES WHERE bacPlId = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLCONT WHERE bacPlId = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLMISC WHERE MISCPLANID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%NEAR%' and RefPlanId = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%WT%' and RefPlanId = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLREFDESCOMP WHERE REFCOMPPLID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%OLD%' and RefPlanId = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%GD%' and RefPlanId = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLROUTE WHERE  rPlId= '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLWIRES WHERE WIRESPLID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLWIRESREMOVE WHERE WIRESPLID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLWIRESADD WHERE WIRESPLID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLWIRESREVISE WHERE WIRESPLID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM tblWiresBackshell WHERE WIRESPLID = '" + plnumber + "'"));
                                data.ExecuteSQL(("DELETE * FROM TBLSELHARNESS WHERE hrnSelPlId = '" + plnumber + "'"));
                                data.ExecuteSQL(("UPDATE TBLREFDES SET OPN ='2' WHERE RefPlanId ='" + plnumber + "'"));
                                data2.ExecuteSQL(string.Concat(new string[] {
                  "INSERT INTO TBLSELHARNESS (hrnSelPlId,OLDHRN,NEWHRN) VALUES ('",
                  plnumber,
                  "','",
                  Module1.newModule.OldHarnessPTP,
                  "','",
                  Module1.newModule.NewHarnessPTP,
                  "')"
                }));
                                try
                                {
                                    pr1.Properties.Maximum = 100;
                                    pr1.EditValue = 0;
                                    pr1.Update();
                                    Cursor.Current = Cursors.WaitCursor;
                                    this.mr2.Visible = true;
                                    this.mr2.Properties.ShowTitle = true;
                                    this.mr2.Text = "Comparing removed wires....";
                                    updatethread = new Thread(QueryDataBase);
                                    updatethread.IsBackground = true;
                                    updatethread.Name = "UpdateThread";
                                    updatethread.Start();
                                    Module1.newModule.ISRUNN = true;
                                    do
                                    {
                                        Application.DoEvents();
                                    } while (Module1.newModule.ISRUNN);
                                    this.mr2.Visible = false;
                                    this.pr1.EditValue = 100;
                                    this.pr1.Update();
                                }
                                catch (Exception exception4)
                                {

                                    Exception exception2 = exception4;
                                    //XtraMessageBox.Show(exception2.Message)

                                }
                                aset = dsql.Copy();
                                this.pr1.Properties.ShowTitle = true;
                                int num9 = (aset.Tables[0].Rows.Count - 1);
                                int i = 0;
                                while ((i <= num9))
                                {
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.Text = "Saving data please wait ....";
                                    this.pr1.EditValue = (i + 1);
                                    this.pr1.Update();
                                    DataRow row = aset.Tables[0].Rows[i];
                                    string source = Conversions.ToString(row[7]);
                                    string str9 = Conversions.ToString(row[4]);
                                    string str8 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row[8])));
                                    string str3 = "REMOVE";
                                    string str7 = Conversions.ToString(row[10]);
                                    string str5 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row[9])));
                                    if (((str5.Contains("STRIP") & source.EndsWith("A")) && !str9.Contains("SH")))
                                    {
                                        str5 = "16VE049012-1";
                                    }
                                    if (((str5.Contains("STRIP") & source.EndsWith("B")) && !str9.Contains("SH")))
                                    {
                                        str5 = "16VE049012-1";
                                    }
                                    Module1.newModule.EndPoint = Conversions.ToString(row[6]);
                                    //If (((LikeString(source, "*S77*", CompareMethod.Binary) Or LikeOperator.LikeString(source, "*77#[A-Z]*", CompareMethod.Binary)) Or LikeOperator.LikeString(source, "*73#[A-Z]", CompareMethod.Binary)) AndAlso Not LikeOperator.LikeString(str9, "*SH*", CompareMethod.Binary)) Then
                                    //    Module1.wireno1 = str9
                                    //    Dim set3 As New DataSet
                                    //    set3 = data.getData(String.Concat(New String() {"SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESREMOVE WHERE WIRENO ='", Module1.wireno1, "' and WIRESPLID ='", plnumber, "'"}))
                                    //    If (set3.Tables.Item(0).Rows.Count <> 0) Then
                                    //        Module1.refdesidnew = (set3.Tables.Item(0).Rows.Item(0).Item("WREFDESID"))
                                    //        Module1.sRefDes = (set3.Tables.Item(0).Rows.Item(0).Item("SREFDES"))
                                    //        Module1.REFDES1 = source
                                    //    End If
                                    //End If
                                    if ((((LikeOperator.LikeString(source, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(source, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str9, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == source)))
                                    {
                                        if (Module1.newModule.BAckhrn)
                                        {
                                            Module1.newModule.BAckhrn = false;
                                        }
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET PIN = '",
                      source,
                      "' ,SWIRENO ='",
                      str9,
                      "Z' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      source,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREMOVE SET PIN = '",
                      source,
                      "' ,SWIRENO ='",
                      str9,
                      "Z' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      source,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET SWIRENO ='",
                      str9,
                      "ZZ' WHERE WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREMOVE SET SWIRENO ='",
                      str9,
                      "ZZ' WHERE WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");//JMR
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str3,
                      "','",
                      str9,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      source,
                      "','",
                      str7,
                      "','",
                      str5,
                      "','",
                      str9,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresREMOVE ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str3,
                      "','",
                      str9,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      source,
                      "','",
                      str7,
                      "','",
                      str5,
                      "','",
                      str9,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    else
                                    {
                                        string str4;
                                        if (LikeOperator.LikeString(source, "*WT*", CompareMethod.Binary))
                                        {
                                            str4 = "wire tie";
                                        }
                                        else
                                        {
                                            str4 = "connector";
                                        }
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      source,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        DataSet set2 = data.getData(str2);
                                        if ((set2.Tables[0].Rows.Count == 0))
                                        {
                                            data.ExecuteSQL(string.Concat(new string[] {
                        "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                        source,
                        "','',2,'",
                        Module1.newModule.HARNESSID,
                        "','",
                        plnumber,
                        "','Rework wires at ",
                        str4,
                        " ",
                        source,
                        " as follows and per 16PR145','','",
                        source,
                        "')"
                      }));
                                            str2 = string.Concat(new string[] {
                        "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                        source,
                        "' AND REFPLANID ='",
                        plnumber,
                        "'"
                      });
                                            Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        else
                                        {
                                            Module1.newModule.RefDesId = Conversions.ToInteger(set2.Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str3,
                      "','",
                      str9,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str8,
                      "','",
                      str7,
                      "','",
                      str5,
                      "','",
                      str9,
                      "','",
                      source,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresREMOVE ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str3,
                      "','",
                      str9,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId)
                    }, ",'", str8, "','", str7, "','", str5, "','", str9, "','",
                                        source, "','','", plnumber, "','", Module1.newModule.EndPoint, "')");
                                        data.ExecuteSQL(str2);
                                    }
                                    row = null;
                                    i += 1;
                                }
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.EditValue = 0x23;
                                this.pr1.Update();
                                Application.DoEvents();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing added wires....";
                                this.updatethread = new Thread(QueryDataBase2);
                                this.updatethread.IsBackground = true;
                                this.updatethread.Name = "UpdateThread";
                                this.updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                Application.DoEvents();
                                this.mr2.Visible = false;
                                aset = dsql.Copy();
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                int num10 = (aset.Tables[0].Rows.Count - 1);
                                int j = 0;
                                while ((j <= num10))
                                {
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (j + 1);
                                    this.pr1.Update();
                                    DataRow row2 = aset.Tables[0].Rows[j];
                                    string str12 = Conversions.ToString(row2[7]);
                                    string str14 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row2[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row2[8])));
                                    string str10 = "ADD";
                                    string str15 = Conversions.ToString(row2[4]);
                                    string str13 = Conversions.ToString(row2[10]);
                                    string str11 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row2[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row2[9])));
                                    Module1.newModule.EndPoint = Conversions.ToString(row2[6]);
                                    if (((str11.Contains("STRIP") & str12.EndsWith("A")) && !str15.Contains("SH")))
                                    {
                                        str11 = "16VE049012-1";
                                    }
                                    if (((str11.Contains("STRIP") & str12.EndsWith("B")) && !str15.Contains("SH")))
                                    {
                                        str11 = "16VE049012-1";
                                    }
                                    if (((LikeOperator.LikeString(str12, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str12, "*77#[A-Z]*", CompareMethod.Binary)) && !LikeOperator.LikeString(str15, "*SH*", CompareMethod.Binary)))
                                    {
                                        Module1.newModule.wireno1 = str15;
                                        DataSet set5 = new DataSet();
                                        set5 = data.getData("SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESADD WHERE WIRENO ='" + Module1.newModule.wireno1 + "' AND WIRESPLID ='" + plnumber + "'");

                                        if ((set5.Tables[0].Rows.Count != 0))
                                        {
                                            Module1.newModule.refdesidnew = Conversions.ToInteger(set5.Tables[0].Rows[0]["WREFDESID"]);
                                            Module1.newModule.sRefDes = Conversions.ToString(set5.Tables[0].Rows[0]["SREFDES"]);
                                            Module1.newModule.REFDES1 = str12;
                                        }
                                    }
                                    if ((((LikeOperator.LikeString(str12, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str12, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str15, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == str12)))
                                    {
                                        if (Module1.newModule.BAckhrn)
                                        {
                                            Module1.newModule.BAckhrn = false;
                                        }
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET PIN = '",
                      str12,
                      "' ,SWIRENO ='",
                      str15,
                      "Z' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      str12,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESADD SET PIN = '",
                      str12,
                      "' ,SWIRENO ='",
                      str15,
                      "Z' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      str12,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET SWIRENO ='",
                      str15,
                      "ZZ' WHERE SWIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESADD SET SWIRENO ='",
                      str15,
                      "ZZ' WHERE SWIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str10,
                      "','",
                      str15,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      str12,
                      "','",
                      str13,
                      "','",
                      str11,
                      "','",
                      str15,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresADD ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str10,
                      "','",
                      str15,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      str12,
                      "','",
                      str13,
                      "','",
                      str11,
                      "','",
                      str15,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    else
                                    {
                                        string str16;
                                        if (LikeOperator.LikeString(str12, "*WT*", CompareMethod.Binary))
                                        {
                                            str16 = "wire tie";
                                        }
                                        else if (LikeOperator.LikeString(str12, "*E*", CompareMethod.Binary))
                                        {
                                            str16 = "wire tie";
                                        }
                                        else
                                        {
                                            str16 = "connector";
                                        }
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str12,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        DataSet set4 = data.getData(str2);
                                        if ((set4.Tables[0].Rows.Count == 0))
                                        {
                                            data.ExecuteSQL(string.Concat(new string[] {
                        "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                        str12,
                        "','',2,'",
                        Module1.newModule.HARNESSID,
                        "','",
                        plnumber,
                        "','Rework wires at ",
                        str16,
                        " ",
                        str12,
                        " as follows and per 16PR145','','",
                        str12,
                        "')"
                      }));
                                            str2 = string.Concat(new string[] {
                        "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                        str12,
                        "' AND REFPLANID ='",
                        plnumber,
                        "'"
                      });
                                            Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        else
                                        {
                                            Module1.newModule.RefDesId = Conversions.ToInteger(set4.Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str10,
                      "','",
                      str15,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str14,
                      "','",
                      str13,
                      "','",
                      str11,
                      "','",
                      str15,
                      "','",
                      str12,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresADD ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str10,
                      "','",
                      str15,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str14,
                      "','",
                      str13,
                      "','",
                      str11,
                      "','",
                      str15,
                      "','",
                      str12,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    row2 = null;
                                    j += 1;
                                }
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.Update();
                                Application.DoEvents();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing removed parts....";
                                this.updatethread = new Thread(QueryDataBase3);
                                this.updatethread.IsBackground = true;
                                this.updatethread.Name = "UpdateThread";
                                this.updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                this.mr2.Visible = false;
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                aset = dsql.Copy();
                                int num11 = (aset.Tables[0].Rows.Count - 1);
                                int k = 0;
                                while ((k <= num11))
                                {
                                    string str18;
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (k + 1);
                                    this.pr1.Update();
                                    DataRow row3 = aset.Tables[0].Rows[k];
                                    DataSet set6 = new DataSet();
                                    string str21 = Conversions.ToString(row3[4]);
                                    string str19 = Conversions.ToString(row3[5]);
                                    string str17 = Conversions.ToString(row3[8]);
                                    string str20 = Conversions.ToString(row3[7]);
                                    if (LikeOperator.LikeString(str21, "%WT%", CompareMethod.Binary))
                                    {
                                        str18 = "wire tie";
                                    }
                                    else
                                    {
                                        str18 = "connector";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str21,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    set6 = data.getData(str2);
                                    if ((set6.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str21,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str18,
                      " ",
                      str21,
                      " as follows and per 16PR145','','",
                      str21,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str21,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set6.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblREFDESCOMP";
                                    str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str19,
                    "','",
                    str17,
                    "','",
                    str20,
                    "','REMOVE','",
                    str21,
                    "','",
                    Module1.newModule.HARNESSID,
                    "','",
                    plnumber,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ")"
                  });
                                    data.ExecuteSQL(str2);
                                    row3 = null;
                                    k += 1;
                                }
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.EditValue = 0x23;
                                this.pr1.Update();
                                Application.DoEvents();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing added parts....";
                                this.updatethread = new Thread(QueryDataBase4);
                                this.updatethread.IsBackground = true;
                                this.updatethread.Name = "UpdateThread";
                                this.updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                this.mr2.Visible = false;
                                aset = dsql.Copy();
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                if ((aset != null))
                                {
                                    int num12 = (aset.Tables[0].Rows.Count - 1);
                                    int m = 0;
                                    while ((m <= num12))
                                    {
                                        string str23;
                                        this.pr1.Properties.Minimum = 1;
                                        this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                        this.pr1.EditValue = (m + 1);
                                        this.pr1.Update();
                                        DataRow row4 = aset.Tables[0].Rows[m];
                                        string str26 = Conversions.ToString(row4[4]);
                                        string str24 = Conversions.ToString(row4[5]);
                                        string str22 = Conversions.ToString(row4[8]);
                                        string str25 = Conversions.ToString(row4[7]);
                                        if (LikeOperator.LikeString(str26, "%WT%", CompareMethod.Binary))
                                        {
                                            str23 = "wire tie";
                                        }
                                        else
                                        {
                                            str23 = "";
                                        }
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str26,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        DataSet set7 = data.getData(str2);
                                        if ((set7.Tables[0].Rows.Count == 0))
                                        {
                                            data.ExecuteSQL(string.Concat(new string[] {
                        "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                        str26,
                        "','',2,'",
                        Module1.newModule.HARNESSID,
                        "','",
                        plnumber,
                        "','Rework wires at ",
                        str23,
                        " ",
                        str26,
                        " as follows and per 16PR145','','",
                        str26,
                        "')"
                      }));
                                            str2 = string.Concat(new string[] {
                        "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                        str26,
                        "' AND REFPLANID ='",
                        plnumber,
                        "'"
                      });
                                            Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        else
                                        {
                                            Module1.newModule.RefDesId = Conversions.ToInteger(set7.Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        str2 = "INSERT INTO tblREFDESCOMP";
                                        str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str24,
                      "','",
                      str22,
                      "','",
                      str25,
                      "','ADD','",
                      str26,
                      "','",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ")"
                    });
                                        data.ExecuteSQL(str2);
                                        row4 = null;
                                        m += 1;
                                    }
                                }
                            }
                            else
                            {
                                Module1.newModule.dashl = Module1.newModule.DrwNo.Length;
                                Module1.newModule.oldval = Conversions.ToInteger(Module1.newModule.OldHarnessPTP.Substring((Module1.newModule.dashl + 1), (Module1.newModule.OldHarnessPTP.Length - (Module1.newModule.dashl + 1))));
                                Module1.newModule.newval = Conversions.ToInteger(Module1.newModule.NewHarnessPTP.Substring((Module1.newModule.dashl + 1), (Module1.newModule.NewHarnessPTP.Length - (Module1.newModule.dashl + 1))));
                                try
                                {
                                    this.pr1.Properties.Maximum = 100;
                                    this.pr1.EditValue = 0x23;
                                    this.pr1.Update();
                                    Cursor.Current = Cursors.WaitCursor;
                                    this.mr2.Visible = true;
                                    this.mr2.Properties.ShowTitle = true;
                                    this.mr2.Text = "Comparing removed wires....";
                                    updatethread = (Thread)UpdateThreadStartPTP1;
                                    updatethread.IsBackground = true;
                                    updatethread.Name = "UpdateThread";
                                    updatethread.Start();
                                    Module1.newModule.ISRUNN = true;
                                    do
                                    {
                                        Application.DoEvents();
                                    } while (Module1.newModule.ISRUNN);
                                    this.mr2.Visible = false;
                                    aset = dsql.Copy();
                                    this.pr1.Properties.ShowTitle = true;
                                    this.pr1.Text = "Saving data please wait ....";
                                    this.pr1.EditValue = 100;
                                    this.pr1.Update();
                                }
                                catch (Exception exception5)
                                {
                                    ProjectData.SetProjectError(exception5);
                                    Exception exception3 = exception5;
                                    //  XtraMessageBox.Show(exception3.Message)
                                    ProjectData.ClearProjectError();
                                }
                                int num13 = (aset.Tables[0].Rows.Count - 1);
                                int n = 0;
                                while ((n <= num13))
                                {
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (n + 1);
                                    this.pr1.Update();
                                    DataRow row5 = aset.Tables[0].Rows[n];
                                    string str30 = Conversions.ToString(row5[7]);
                                    string str33 = Conversions.ToString(row5[4]);
                                    string str32 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row5[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row5[8])));
                                    string str27 = "REMOVE";
                                    string str31 = Conversions.ToString(row5[10]);
                                    string str29 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row5[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row5[9])));
                                    if (((str29.Contains("STRIP") & str30.EndsWith("A")) && !str33.Contains("SH")))
                                    {
                                        str29 = "16VE049012-1";
                                    }
                                    if (((str29.Contains("STRIP") & str30.EndsWith("B")) && !str33.Contains("SH")))
                                    {
                                        str29 = "16VE049012-1";
                                    }
                                    Module1.newModule.EndPoint = Conversions.ToString(row5[6]);
                                    if ((((LikeOperator.LikeString(str30, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str30, "*77#[A-Z]*", CompareMethod.Binary)) | LikeOperator.LikeString(str30, "*73#[A-Z]", CompareMethod.Binary)) && !LikeOperator.LikeString(str33, "*SH*", CompareMethod.Binary)))
                                    {
                                        Module1.newModule.wireno1 = str33;
                                        DataSet set9 = new DataSet();
                                        set9 = data.getData(string.Concat(new string[] {
                      "SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESREMOVE WHERE WIRENO ='",
                      Module1.newModule.wireno1,
                      "' and WIRESPLID ='",
                      plnumber,
                      "'"
                    }));
                                        if ((set9.Tables[0].Rows.Count != 0))
                                        {
                                            Module1.newModule.refdesidnew = Conversions.ToInteger(set9.Tables[0].Rows[0]["WREFDESID"]);
                                            Module1.newModule.sRefDes = Conversions.ToString(set9.Tables[0].Rows[0]["SREFDES"]);
                                            Module1.newModule.REFDES1 = str30;
                                        }
                                    }
                                    if ((((LikeOperator.LikeString(str30, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str30, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str33, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == str30)))
                                    {
                                        if (Module1.newModule.BAckhrn)
                                        {
                                            Module1.newModule.BAckhrn = false;
                                        }
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET PIN = '",
                      str30,
                      "' ,SWIRENO ='",
                      str33,
                      "Zz' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      str30,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREMOVE SET PIN = '",
                      str30,
                      "' ,SWIRENO ='",
                      str33,
                      "Zz' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      str30,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET SWIRENO ='",
                      str33,
                      "Z' WHERE WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESREMOVE SET SWIRENO ='",
                      str33,
                      "Z' WHERE WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str27,
                      "','",
                      str33,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      str30,
                      "','",
                      str31,
                      "','",
                      str29,
                      "','",
                      str33,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresREMOVE ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str27,
                      "','",
                      str33,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      str30,
                      "','",
                      str31,
                      "','",
                      str29,
                      "','",
                      str33,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    else
                                    {
                                        string str28;
                                        if (LikeOperator.LikeString(str30, "*WT*", CompareMethod.Binary))
                                        {
                                            str28 = "wire tie";
                                        }
                                        else
                                        {
                                            str28 = "connector";
                                        }
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str30,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        DataSet set8 = data.getData(str2);
                                        if ((set8.Tables[0].Rows.Count == 0))
                                        {
                                            data.ExecuteSQL(string.Concat(new string[] {
                        "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                        str30,
                        "','',2,'",
                        Module1.newModule.HARNESSID,
                        "','",
                        plnumber,
                        "','Rework wires at ",
                        str28,
                        " ",
                        str30,
                        " as follows and per 16PR145','','",
                        str30,
                        "')"
                      }));
                                            str2 = string.Concat(new string[] {
                        "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                        str30,
                        "' AND REFPLANID ='",
                        plnumber,
                        "'"
                      });
                                            Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        else
                                        {
                                            Module1.newModule.RefDesId = Conversions.ToInteger(set8.Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str27,
                      "','",
                      str33,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str32,
                      "','",
                      str31,
                      "','",
                      str29,
                      "','",
                      str33,
                      "','",
                      str30,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresREMOVE ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str27,
                      "','",
                      str33,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str32,
                      "','",
                      str31,
                      "','",
                      str29,
                      "','",
                      str33,
                      "','",
                      str30,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    row5 = null;
                                    n += 1;
                                }
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.EditValue = 0x23;
                                this.pr1.Update();
                                Application.DoEvents();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing added wires....";
                                this.updatethread = (Thread)UpdateThreadStartPTP2;
                                this.updatethread.IsBackground = true;
                                this.updatethread.Name = "UpdateThread";
                                this.updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                this.mr2.Visible = false;
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                aset = dsql.Copy();
                                int num14 = (aset.Tables[0].Rows.Count - 1);
                                int num6 = 0;
                                while ((num6 <= num14))
                                {
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (num6 + 1);
                                    this.pr1.Update();
                                    DataRow row6 = aset.Tables[0].Rows[num6];
                                    string str36 = Conversions.ToString(row6[7]);
                                    string str38 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row6[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row6[8])));
                                    string str34 = "ADD";
                                    string str39 = Conversions.ToString(row6[4]);
                                    string str37 = Conversions.ToString(row6[10]);
                                    string str35 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row6[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row6[9])));
                                    Module1.newModule.EndPoint = Conversions.ToString(row6[6]);
                                    if (((str35.Contains("STRIP") & str36.EndsWith("A")) && !str39.Contains("SH")))
                                    {
                                        str35 = "16VE049012-1";
                                    }
                                    if (((str35.Contains("STRIP") & str36.EndsWith("B")) && !str39.Contains("SH")))
                                    {
                                        str35 = "16VE049012-1";
                                    }
                                    if (((LikeOperator.LikeString(str36, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str36, "*77#[A-Z]*", CompareMethod.Binary)) && !LikeOperator.LikeString(str39, "*SH*", CompareMethod.Binary)))
                                    {
                                        Module1.newModule.wireno1 = str39;
                                        DataSet set11 = new DataSet();
                                        set11 = data.getData(string.Concat(new string[] {
                      "SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESADD WHERE WIRENO ='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID ='",
                      plnumber,
                      "'"
                    }));
                                        if ((set11.Tables[0].Rows.Count != 0))
                                        {
                                            Module1.newModule.refdesidnew = Conversions.ToInteger(set11.Tables[0].Rows[0]["WREFDESID"]);
                                            Module1.newModule.sRefDes = Conversions.ToString(set11.Tables[0].Rows[0]["SREFDES"]);
                                            Module1.newModule.REFDES1 = str36;
                                        }
                                    }
                                    if ((((LikeOperator.LikeString(str36, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str36, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str39, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == str36)))
                                    {
                                        if (Module1.newModule.BAckhrn)
                                        {
                                            Module1.newModule.BAckhrn = false;
                                        }
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET PIN = '",
                      str36,
                      "' ,SWIRENO ='",
                      str39,
                      "Z' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      str36,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESADD SET PIN = '",
                      str36,
                      "' ,SWIRENO ='",
                      str39,
                      "Z' , WREFDESID = ",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      " ,SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' WHERE SREFDES ='",
                      str36,
                      "' AND WIRENO='",
                      Module1.newModule.wireno1,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRES SET SWIRENO ='",
                      str39,
                      "ZZ' WHERE SWIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "UPDATE TBLWIRESADD SET SWIRENO ='",
                      str39,
                      "ZZ' WHERE SWIRENO='",
                      Module1.newModule.wireno1,
                      "' AND SREFDES ='",
                      Module1.newModule.sRefDes,
                      "' AND WIRESPLID = '",
                      plnumber,
                      "'"
                    }));
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str34,
                      "','",
                      str39,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      str36,
                      "','",
                      str37,
                      "','",
                      str35,
                      "','",
                      str39,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresADD ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str34,
                      "','",
                      str39,
                      "',",
                      Conversions.ToString(Module1.newModule.refdesidnew),
                      ",'",
                      str36,
                      "','",
                      str37,
                      "','",
                      str35,
                      "','",
                      str39,
                      "','",
                      Module1.newModule.sRefDes,
                      "','','",
                      plnumber,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    else
                                    {
                                        string str40;
                                        if (LikeOperator.LikeString(str36, "*WT*", CompareMethod.Binary))
                                        {
                                            str40 = "wire tie";
                                        }
                                        else
                                        {
                                            str40 = "connector";
                                        }
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str36,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        DataSet set10 = data.getData(str2);
                                        if ((set10.Tables[0].Rows.Count == 0))
                                        {
                                            data.ExecuteSQL(string.Concat(new string[] {
                        "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                        str36,
                        "','',2,'",
                        Module1.newModule.HARNESSID,
                        "','",
                        plnumber,
                        "','Rework wires at ",
                        str40,
                        " ",
                        str36,
                        " as follows and per 16PR145','','",
                        str36,
                        "')"
                      }));
                                            str2 = string.Concat(new string[] {
                        "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                        str36,
                        "' AND REFPLANID ='",
                        plnumber,
                        "'"
                      });
                                            Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        else
                                        {
                                            Module1.newModule.RefDesId = Conversions.ToInteger(set10.Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        str2 = "INSERT INTO tblWires ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str34,
                      "','",
                      str39,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str38,
                      "','",
                      str37,
                      "','",
                      str35,
                      "','",
                      str39,
                      "','",
                      str36,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                        str2 = "INSERT INTO tblWiresADD ";
                                        str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str34,
                      "','",
                      str39,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ",'",
                      str38,
                      "','",
                      str37,
                      "','",
                      str35,
                      "','",
                      str39,
                      "','",
                      str36,
                      "','','",
                      plnumber,
                      "','",
                      Module1.newModule.EndPoint,
                      "')"
                    });
                                        data.ExecuteSQL(str2);
                                    }
                                    row6 = null;
                                    num6 += 1;
                                }
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.EditValue = 0x23;
                                this.pr1.Update();
                                Application.DoEvents();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing removed parts....";
                                this.updatethread = (Thread)UpdateThreadStartCBE1;
                                this.updatethread.IsBackground = true;
                                this.updatethread.Name = "UpdateThread";
                                this.updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                this.mr2.Visible = false;
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                aset = dsql.Copy();
                                int num15 = (aset.Tables[0].Rows.Count - 1);
                                int num7 = 0;
                                while ((num7 <= num15))
                                {
                                    string str42;
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (num7 + 1);
                                    this.pr1.Update();
                                    DataRow row7 = aset.Tables[0].Rows[num7];
                                    DataSet set12 = new DataSet();
                                    string str45 = Conversions.ToString(row7[4]);
                                    string str43 = Conversions.ToString(row7[5]);
                                    string str41 = Conversions.ToString(row7[8]);
                                    string str44 = Conversions.ToString(row7[7]);
                                    if (LikeOperator.LikeString(str45, "%WT%", CompareMethod.Binary))
                                    {
                                        str42 = "wire tie";
                                    }
                                    else
                                    {
                                        str42 = "connector";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str45,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    set12 = data.getData(str2);
                                    if ((set12.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str45,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str42,
                      " ",
                      str45,
                      " as follows and per 16PR145','','",
                      str45,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str45,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set12.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblREFDESCOMP";
                                    str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str43,
                    "','",
                    str41,
                    "','",
                    str44,
                    "','REMOVE','",
                    str45,
                    "','",
                    Module1.newModule.HARNESSID,
                    "','",
                    plnumber,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ")"
                  });
                                    data.ExecuteSQL(str2);
                                    row7 = null;
                                    num7 += 1;
                                }
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.EditValue = 100;
                                this.pr1.Update();
                                Application.DoEvents();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing added parts....";
                                this.updatethread = (Thread)UpdateThreadStartCBE2;
                                this.updatethread.IsBackground = true;
                                this.updatethread.Name = "UpdateThread";
                                this.updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                aset = dsql.Copy();
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                this.mr2.Visible = false;
                                if ((aset != null))
                                {
                                    int num16 = (aset.Tables[0].Rows.Count - 1);
                                    int num8 = 0;
                                    while ((num8 <= num16))
                                    {
                                        string str47;
                                        this.pr1.Properties.Minimum = 1;
                                        this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                        this.pr1.EditValue = (num8 + 1);
                                        this.pr1.Update();
                                        DataRow row8 = aset.Tables[0].Rows[num8];
                                        string str50 = Conversions.ToString(row8[4]);
                                        string str48 = Conversions.ToString(row8[5]);
                                        string str46 = Conversions.ToString(row8[8]);
                                        string str49 = Conversions.ToString(row8[7]);
                                        if (LikeOperator.LikeString(str50, "%WT%", CompareMethod.Binary))
                                        {
                                            str47 = "wire tie";
                                        }
                                        else
                                        {
                                            str47 = "";
                                        }
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str50,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        DataSet set13 = data.getData(str2);
                                        if ((set13.Tables[0].Rows.Count == 0))
                                        {
                                            data.ExecuteSQL(string.Concat(new string[] {
                        "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                        str50,
                        "','',2,'",
                        Module1.newModule.HARNESSID,
                        "','",
                        plnumber,
                        "','Rework wires at ",
                        str47,
                        " ",
                        str50,
                        " as follows and per 16PR145','','",
                        str50,
                        "')"
                      }));
                                            str2 = string.Concat(new string[] {
                        "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                        str50,
                        "' AND REFPLANID ='",
                        plnumber,
                        "'"
                      });
                                            Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        else
                                        {
                                            Module1.newModule.RefDesId = Conversions.ToInteger(set13.Tables[0].Rows[0]["REFDESID"]);
                                        }
                                        str2 = "INSERT INTO tblREFDESCOMP";
                                        str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                        str2 = string.Concat(new string[] {
                      str2,
                      "('",
                      str48,
                      "','",
                      str46,
                      "','",
                      str49,
                      "','ADD','",
                      str50,
                      "','",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "',",
                      Conversions.ToString(Module1.newModule.RefDesId),
                      ")"
                    });
                                        data.ExecuteSQL(str2);
                                        row8 = null;
                                        num8 += 1;
                                    }
                                }
                            }
                            Module1.newModule.makewiresb = true;
                            this.updatethread = (Thread)UpdateThreadStartWires;
                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();

                            do
                            {
                                Application.DoEvents();
                                this.mr2.Visible = true;
                                this.mr2.Text = "Saving data please wait...";
                            } while (Module1.newModule.makewiresb);
                            aset = null;
                            this.FormCloseex2 = false;
                            this.pr1.EditValue = 100;
                            this.pr1.Update();
                            this.Close();
                        }
                        else
                        {
                            this.txtNewHarnesPTP.Text = "";
                            this.txtOldHarnessPTP.Text = "";
                            Module1.newModule.oldSel = false;
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Wrong selection select again Old  harness");
                        this.txtNewHarnesPTP.Text = "";
                        this.txtOldHarnessPTP.Text = "";
                        Module1.newModule.oldSel = false;
                    }
                }
            }
        }
        public static void QueryDataBase()
        {
            DataSet dsPtp = new DataSet();
            Application.DoEvents();
            DataSet PDA = new DataSet();
            clsData PDL = new clsData();
            // PDL.ExecuteSQL("DELETE * FROM PTP WHERE  PART_NUMBER <> '" & OldHarnessPTP & "' AND PART_NUMBER <> '" & NewHarnessPTP & "'")
            // PDL.ExecuteSQL("DELETE * FROM CBE WHERE  DWG_DASH <> '" & OldHarnessPTP & "' AND DWG_DASH <> '" & NewHarnessPTP & "'")

            PDA = PDL.getData("SELECT * FROM PTP WHERE PART_NUMBER = '" + Module1.newModule.OldHarnessPTP + "' OR PART_NUMBER = '" + Module1.newModule.NewHarnessPTP + "'");
            PDA.Tables[0].TableName = "PTP2";

            int num7 = (PDA.Tables["PTP2"].Rows.Count - 1);
            int NUM;
            NUM = 0;
            while ((NUM <= num7))
            {

                PDA.Tables["PTP2"].Rows[NUM].SetAdded();
                NUM += 1;
            }

            IEnumerator enumerator = null;//JMR -- DEV -- look at -- nulled it
            try
            {
                enumerator = PDA.Tables[0].Rows.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    DataRow current = (DataRow)enumerator.Current;
                    dsPtp.Tables["PTP2"].ImportRow(current);

                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            try
            {

            }
            finally
            {

            }
            try
            {

                NUM = 0;
                while ((NUM <= num7))
                {

                    dsPtp.Tables["TP2"].Rows[NUM].SetAdded();
                    NUM += 1;
                }
                dsPtp.AcceptChanges();



                dsPtp.Tables[0].GetChanges();

                dsPtp.HasChanges();

                daPTP2.Update(dsPtp, "PTP2");
            }
            catch (Exception ex)
            {

            }
            daPTP2.Update(dsPtp, "PTP2");



            //4:
            dsql = dcl.getData(string.Concat(new string[] {
        " SELECT * FROM PTP2 TBL1 WHERE  PART_NUMBER = '",
        Module1.newModule.OldHarnessPTP,
        "' AND  WIRE_NUMBER NOT IN( SELECT WIRE_NUMBER FROM PTP2 TBL2 WHERE  (TBL1.WIRE_SPEC_GAGE = TBL2.WIRE_SPEC_GAGE) and((TBL1.WIRE_END_PIN = TBL2.WIRE_END_PIN)OR(TBL2.WIRE_END_PIN like 'c%' AND TBL1.WIRE_END_PIN = '-' )OR(TBL1.WIRE_END_PIN ='-' AND TBL2.WIRE_END_PIN <> '-' AND TBL1.WIRE_NUMBER LIKE '%SHA%')OR(TBL2.WIRE_END_PIN ='-' AND TBL1.WIRE_END_PIN <> '-' AND TBL1.WIRE_NUMBER LIKE '%SHA%') OR (TBL1.WIRE_END_PIN like 'c%' AND TBL2.WIRE_END_PIN = '-' )OR(TBL1.WIRE_END_PIN IS NULL AND TBL2.WIRE_END_PIN = '-' )) AND TBL1.WIRE_END_REF = TBL2.WIRE_END_REF AND ((TBL1.WIRE_END_PN = TBL2.WIRE_END_PN)OR (TBL1.WIRE_END_PN IS NULL AND TBL2.WIRE_END_PIN='-')OR(TBL1.WIRE_END_PN ='M39029/101-552' AND TBL2.WIRE_END_PN ='M39029/22-191') OR(TBL2.WIRE_END_PN ='M39029/101-552' AND TBL1.WIRE_END_PN ='M39029/22-191') OR(TBL1.WIRE_END_REF  LIKE '77[0-9][A-Z]%' AND TBL2.WIRE_END_REF  LIKE '77[0-9][A-Z]%' AND TBL1.WIRE_END_PIN LIKE 'C%' AND TBL2.WIRE_END_PIN ='-')OR(TBL2.WIRE_END_PN ='M39029/5-115' AND ((TBL1.WIRE_NUMBER = TBL2.WIRE_NUMBER) OR (TBL1.WIRE_NUMBER LIKE '%BLK' AND TBL2.WIRE_NUMBER LIKE '%BLK[1-2]%') OR (TBL1.WIRE_NUMBER LIKE '%WHT' AND TBL2.WIRE_NUMBER LIKE '%WHT[1-2]%')) AND TBL1.WIRE_END_PN ='M39029/5-20-20')OR (TBL1.WIRE_END_PN ='M39029/5-115' AND TBL2.WIRE_END_PN ='M39029/5-20-20') OR (TBL1.WIRE_END_PN ='M39029/101-552' AND TBL2.WIRE_END_PN ='M39029/22-191' AND TBL1.WIRE_END_REF NOT LIKE '%GD%' AND TBL2.WIRE_END_REF NOT LIKE '%GD%')OR(((TBL1.WIRE_END_PN ='M39029/22-20-20') OR (TBL1.WIRE_END_PN ='M39029/22-192')) AND TBL2.WIRE_END_PN ='M39029/101-553' AND TBL1.WIRE_END_REF NOT LIKE '%GD%' AND TBL2.WIRE_END_REF NOT LIKE '%GD%')OR(TBL2.WIRE_END_PN ='M39029/4-110' AND TBL1.WIRE_END_PN ='M39029/4-20-20')OR(TBL1.WIRE_END_PN ='M39029/4-110' AND TBL2.WIRE_END_PN ='M39029/4-20-20')OR(TBL2.WIRE_END_PN ='M39029/74-12C' AND TBL1.WIRE_END_PN ='M39029/74-400')OR(TBL2.WIRE_END_PN ='M39029/18-23-22' AND TBL1.WIRE_END_PN ='M39029/18-177')OR(TBL1.WIRE_END_PN ='M39029/18-23-22' AND TBL2.WIRE_END_PN ='M39029/18-177')OR(TBL2.WIRE_END_PN ='M39029/5-117' AND TBL1.WIRE_END_PN ='M39029/5-16-20')OR(TBL1.WIRE_END_PN ='M39029/5-117' AND TBL2.WIRE_END_PN ='M39029/5-16-20')OR(TBL1.WIRE_END_PN ='M39029/5-117' AND TBL2.WIRE_END_PN ='M39029/5-116')OR(TBL1.WIRE_END_PN ='M39029/74-12C' AND TBL2.WIRE_END_PN ='M39029/74-400')OR(TBL2.WIRE_END_PN ='M39029/56-348' AND TBL1.WIRE_END_PN ='MS27490-22D')OR(TBL1.WIRE_END_PN ='M39029/4-110' AND TBL2.WIRE_END_PN ='M39029/4-111')OR(TBL1.WIRE_END_PN ='M39029/4-110' AND TBL2.WIRE_END_PN ='M39029/4-112')OR(TBL1.WIRE_END_PN ='M39029/4-112' AND TBL2.WIRE_END_PN ='M39029/4-111')OR(TBL1.WIRE_END_PN ='M39029/5-115' AND TBL2.WIRE_END_PN ='M39029/4-116')OR(TBL1.WIRE_END_PN ='M39029/5-116' AND TBL2.WIRE_END_PN ='M39029/5-117')OR(TBL1.WIRE_END_PN ='M39029/5-116' AND TBL2.WIRE_END_PN ='M39029/4-117')) AND ((TBL1.WIRE_LEN_MEAS = TBL1.WIRE_LEN_MEAS)OR(TBL1.WIRE_LEN_MEAS ='9998' AND TBL2.WIRE_LEN_MEAS ='9992')OR(TBL1.WIRE_LEN_MEAS ='0001')OR(TBL2.WIRE_LEN_MEAS ='0001')OR(TBL1.WIRE_LEN_MEAS ='0002')OR(TBL2.WIRE_LEN_MEAS ='0002')) AND TBL2.PART_NUMBER = '",
        Module1.newModule.NewHarnessPTP,
        "') ORDER BY TBL1.WIRE_END_PIN DESC,TBL1.WIRE_END_REF DESC,TBL1.WIRE_END_PN ,TBL1.WIRE_LEN_MEAS DESC"
      }));
            // Me.BeginInvoke(CallDataBindToDataGrid)

            Module1.newModule.ISRUNN = false;
        }
        public static void QueryDataBase2()
        {
            Application.DoEvents();
            dsql = dcl.getData(string.Concat(new string[] {
        " SELECT * FROM PTP2 TBL1 WHERE  PART_NUMBER = '",
        Module1.newModule.NewHarnessPTP,
        "' AND  WIRE_NUMBER NOT IN( SELECT WIRE_NUMBER FROM PTP2 TBL2 WHERE (TBL1.WIRE_SPEC_GAGE = TBL2.WIRE_SPEC_GAGE) and ((TBL1.WIRE_END_PIN = TBL2.WIRE_END_PIN)OR(TBL2.WIRE_END_PIN like 'c%' AND TBL1.WIRE_END_PIN = '-' ) OR (TBL1.WIRE_END_PIN ='-' AND TBL2.WIRE_END_PIN <> '-' AND TBL1.WIRE_NUMBER LIKE '%SHA%')OR(TBL2.WIRE_END_PIN ='-' AND TBL1.WIRE_END_PIN <> '-' AND TBL1.WIRE_NUMBER LIKE '%SHA%')OR(TBL1.WIRE_END_PIN like 'c%' AND TBL2.WIRE_END_PIN = '-' )OR(TBL1.WIRE_END_PIN IS NULL AND TBL2.WIRE_END_PIN = '-' )) AND TBL1.WIRE_END_REF = TBL2.WIRE_END_REF AND ((TBL1.WIRE_END_PN = TBL2.WIRE_END_PN)OR (TBL1.WIRE_END_PN IS NULL AND TBL2.WIRE_END_PIN='-')OR(TBL1.WIRE_END_PN ='M39029/5-115' AND TBL2.WIRE_END_PN ='M39029/5-20-20')OR(TBL1.WIRE_END_PN ='M39029/101-552' AND TBL2.WIRE_END_PN ='M39029/22-191')OR(TBL2.WIRE_END_PN ='M39029/101-552' AND TBL1.WIRE_END_PN ='M39029/22-191') OR(TBL1.WIRE_END_REF  LIKE '77[0-9][A-Z]%' AND TBL2.WIRE_END_REF  LIKE '77[0-9][A-Z]%' AND TBL1.WIRE_END_PIN LIKE 'C%' AND TBL2.WIRE_END_PIN ='-') OR(TBL2.WIRE_END_PN ='M39029/5-115' AND TBL1.WIRE_END_PN ='M39029/5-20-20') OR(TBL2.WIRE_END_PN ='M39029/18-23-22' AND TBL1.WIRE_END_PN ='M39029/18-177')OR(TBL1.WIRE_END_PN ='M39029/18-23-22' AND TBL2.WIRE_END_PN ='M39029/18-177')OR (TBL2.WIRE_END_PN ='M39029/101-552' AND TBL1.WIRE_END_PN ='M39029/22-191' AND TBL2.WIRE_END_REF NOT LIKE '%GD%' AND TBL1.WIRE_END_REF NOT LIKE '%GD%')OR(((TBL2.WIRE_END_PN ='M39029/22-20-20') OR (TBL2.WIRE_END_PN ='M39029/22-192')) AND TBL1.WIRE_END_PN ='M39029/101-553' AND TBL1.WIRE_END_REF NOT LIKE '%GD%' AND TBL2.WIRE_END_REF NOT LIKE '%GD%')OR(TBL1.WIRE_END_PN ='M39029/4-110' AND TBL2.WIRE_END_PN ='M39029/4-20-20')OR(TBL2.WIRE_END_PN ='M39029/4-110' AND TBL1.WIRE_END_PN ='M39029/4-20-20')OR(TBL2.WIRE_END_PN ='M39029/5-117' AND TBL1.WIRE_END_PN ='M39029/5-16-20')OR(TBL1.WIRE_END_PN ='M39029/5-117' AND TBL2.WIRE_END_PN ='M39029/5-16-20')OR(TBL2.WIRE_END_PN ='M39029/74-12C' AND TBL1.WIRE_END_PN ='M39029/74-400')OR(TBL1.WIRE_END_PN ='M39029/5-117' AND TBL2.WIRE_END_PN ='M39029/5-116')OR(TBL1.WIRE_END_PN ='M39029/74-12C' AND TBL2.WIRE_END_PN ='M39029/74-400')OR(TBL1.WIRE_END_PN ='M39029/56-348' AND TBL2.WIRE_END_PN ='MS27490-22D')OR(TBL2.WIRE_END_PN ='M39029/4-110' AND TBL1.WIRE_END_PN ='M39029/4-111')OR(TBL2.WIRE_END_PN ='M39029/4-110' AND TBL1.WIRE_END_PN ='M39029/4-112')OR(TBL2.WIRE_END_PN ='M39029/4-112' AND TBL1.WIRE_END_PN ='M39029/4-111')OR(TBL1.WIRE_END_PN ='M39029/5-115' AND TBL2.WIRE_END_PN ='M39029/4-116')OR(TBL2.WIRE_END_PN ='M39029/5-115' AND TBL1.WIRE_END_PN ='M39029/5-117')OR(TBL2.WIRE_END_PN ='M39029/5-116' AND TBL1.WIRE_END_PN ='M39029/4-117')) AND ((TBL1.WIRE_LEN_MEAS = TBL1.WIRE_LEN_MEAS)OR(TBL2.WIRE_LEN_MEAS ='9998' AND TBL1.WIRE_LEN_MEAS ='9992')OR(TBL1.WIRE_LEN_MEAS ='0001')OR(TBL2.WIRE_LEN_MEAS ='0001')) AND TBL2.PART_NUMBER = '",
        Module1.newModule.OldHarnessPTP,
        "') ORDER BY TBL1.WIRE_END_PIN DESC,TBL1.WIRE_END_REF DESC,TBL1.WIRE_END_PN ,TBL1.WIRE_LEN_MEAS DESC "
      }));
            //Me.BeginInvoke(Me.CallDataBindToDataGrid)
            Module1.newModule.ISRUNN = false;
        }

        public static void QueryDataBase3()
        {
            DataSet dsPtp = new DataSet();
            DataSet pda = new DataSet();
            clsData pdl = new clsData();
            Application.DoEvents();
            pda = pdl.getData("SELECT * FROM cbe WHERE DWG_DASH = '" + Module1.newModule.OldHarnessPTP + "' OR DWG_DASH = '" + Module1.newModule.NewHarnessPTP + "'");
            pda.Tables[0].TableName = "CBE2";

            int num7 = (pda.Tables["CBE2"].Rows.Count - 1);
            int NUM;
            NUM = 0;
            while ((NUM <= num7))
            {

                pda.Tables["CBE2"].Rows[NUM].SetAdded();
                NUM += 1;
            }

            IEnumerator enumerator = null;//JMR -- DEV -- look at -- nulled it
            try
            {
                enumerator = pda.Tables[0].Rows.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    DataRow current = (DataRow)enumerator.Current;
                    dsPtp.Tables["CBE2"].ImportRow(current);

                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            try
            {

            }
            finally
            {

            }
            try
            {

                NUM = 0;
                while ((NUM <= num7))
                {

                    dsPtp.Tables["CBE2"].Rows[NUM].SetAdded();
                    NUM += 1;
                }
                dsPtp.AcceptChanges();



                dsPtp.Tables[1].GetChanges();

                dsPtp.HasChanges();

                daCBE2.Update(dsPtp, "CBE2");
            }
            catch (Exception ex)
            {

            }
            daCBE2.Update(dsPtp, "CBE2");

            dsql = dcl.getData(string.Concat(new string[] {
        " SELECT * FROM CBE2 TBL1 WHERE DWG_DASH = '",
        Module1.newModule.OldHarnessPTP,
        "' AND  REF_DES NOT IN( SELECT REF_DES FROM CBE2 TBL2 WHERE  TBL1.PTNUMBER = TBL2.PTNUMBER AND ((TBL1.QNA = TBL2.QNA) OR (TBL1.QNA ='9999' AND  TBL2.QNA ='0001'))  AND TBL2.DWG_DASH = '",
        Module1.newModule.NewHarnessPTP,
        "')"
      }));
            // Me.BeginInvoke(Me.CallDataBindToDataGrid)
            Module1.newModule.ISRUNN = false;
        }

        public static void QueryDataBase4()
        {
            Application.DoEvents();
            dsql = dcl.getData(string.Concat(new string[] {
        " SELECT * FROM CBE2 TBL1 WHERE DWG_DASH = '",
        Module1.newModule.NewHarnessPTP,
        "' AND  REF_DES NOT IN( SELECT REF_DES FROM CBE2 TBL2 WHERE  TBL1.PTNUMBER = TBL2.PTNUMBER AND ((TBL1.QNA = TBL2.QNA) OR (TBL2.QNA ='9999' AND  TBL1.QNA ='0001'))  AND TBL2.DWG_DASH = '",
        Module1.newModule.OldHarnessPTP,
        "')"
      }));
            // Me.BeginInvoke(Me.CallDataBindToDataGrid)
            Module1.newModule.ISRUNN = false;
        }
        private static void MakeWires()
        {
            string str;
            string str2;
            DataSet set2 = new DataSet();
            clsData data2 = new clsData();
            DataSet aset = new DataSet();
            clsData data = new clsData();
            Module1.newModule.makewiresb = true;
            set2 = data2.getData(("select * from tblwires WHERE WIRESPLID = '" + Module1.newModule.PlanNumber + "' AND SREFDES LIKE '%J%' order by SREFDES,WIRENO"));
            int num5 = (set2.Tables[0].Rows.Count - 1);
            int i = 0;
            while ((i <= num5))
            {
                int num2 = new int();//JMR -- look at -- changed int num2 to int num2 = new int()
                DataRow row = set2.Tables[0].Rows[i];
                DataSet set3 = new DataSet();
                clsData data3 = new clsData();
                Module1.newModule.WireSpec = Conversions.ToString(row[8]);
                str = Conversions.ToString(row[9]);
                Module1.newModule.wireno1 = Conversions.ToString(row[1]);
                Module1.newModule.end1 = Conversions.ToString(row[7]);
                Module1.newModule.Pin = Conversions.ToString(row[3]);
                Module1.newModule.Term = Conversions.ToString(row[5]);
                Module1.newModule.ACTION = Conversions.ToString(row[0]);
                if ((Module1.newModule.ACTION == "ADD"))
                {
                    Module1.newModule.ACTION = " ADDED";
                    set3 = data3.getData(("SELECT REFDESID  FROM TBLREFDES WHERE REFDES = '" + Module1.newModule.end1 + "'"));
                    if ((set3.Tables[0].Rows.Count == 0))
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
              Module1.newModule.end1,
              "','',2,'",
              Module1.newModule.HARNESSID,
              "','",
              Module1.newModule.PlanNumber,
              "','Rework wires at  ",
              Module1.newModule.end1,
              " as follows and per 16PR145','','",
              Conversions.ToString(num2),
              "')"
            }));
                        str2 = string.Concat(new string[] {
              "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
              Module1.newModule.end1,
              "' AND REFPLANID ='",
              Module1.newModule.PlanNumber,
              "'"
            });
                        num2 = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                    }
                    else
                    {
                        num2 = Conversions.ToInteger(set3.Tables[0].Rows[0]["REFDESID"]);
                    }
                    set3 = data3.getData(string.Concat(new string[] {
            "select * from PTP where WIRE_NUMBER = '",
            Module1.newModule.wireno1,
            "' and ((WIRE_END_REF <> '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "') or (WIRE_END_REF = '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "')) AND PART_NUMBER ='",
            Module1.newModule.NewHarnessPTP,
            "'"
          }));
                    if ((set3.Tables[0].Rows.Count != 0))
                    {
                        Module1.newModule.end2 = Conversions.ToString(set3.Tables[0].Rows[0]["WIRE_END_REF"]);
                        Module1.newModule.pin2 = Conversions.ToString(set3.Tables[0].Rows[0]["WIRE_END_PIN"]);
                        Module1.newModule.term2 = Conversions.ToString(set3.Tables[0].Rows[0]["WIRE_END_PN"]);
                    }
                }
                else if ((Module1.newModule.ACTION == "REMOVE"))
                {
                    Module1.newModule.ACTION = "REMOVED";
                    set3 = data3.getData(("SELECT REFDESID FROM TBLREFDES WHERE REFDES = '" + Module1.newModule.end1 + "'"));
                    if ((set3.Tables[0].Rows.Count == 0))
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
              Module1.newModule.end1,
              "','',2,'",
              Module1.newModule.HARNESSID,
              "','",
              Module1.newModule.PlanNumber,
              "','Rework wires at  ",
              Module1.newModule.end1,
              " as follows and per 16PR145','','",
              Module1.newModule.end1,
              "')"
            }));
                        str2 = string.Concat(new string[] {
              "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
              Module1.newModule.end1,
              "' AND REFPLANID ='",
              Module1.newModule.PlanNumber,
              "'"
            });
                        num2 = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                    }
                    else
                    {
                        num2 = Conversions.ToInteger(set3.Tables[0].Rows[0]["REFDESID"]);
                    }
                    set3 = data3.getData(string.Concat(new string[] {
            "select * from PTP where WIRE_NUMBER = '",
            Module1.newModule.wireno1,
            "' and ((WIRE_END_REF <> '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "') or (WIRE_END_REF = '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "')) AND PART_NUMBER ='",
            Module1.newModule.OldHarnessPTP,
            "'"
          }));
                    if ((set3.Tables[0].Rows.Count != 0))
                    {
                        Module1.newModule.end2 = Conversions.ToString(set3.Tables[0].Rows[0]["WIRE_END_REF"]);
                        Module1.newModule.pin2 = Conversions.ToString(set3.Tables[0].Rows[0]["WIRE_END_PIN"]);
                        Module1.newModule.term2 = Conversions.ToString(set3.Tables[0].Rows[0]["WIRE_END_PN"]);
                    }
                }
                str2 = "INSERT INTO tblBackShopWires";
                str2 = (str2 + "(bacPlid,bacREFDES1,bacPIN1,bacTerm1,bacWIRENO,bacREFDES2,bacPin2,bacTerm2,bacWIRESPEC,bacAction) values");
                str2 = string.Concat(new string[] {
          str2,
          "('",
          Module1.newModule.PlanNumber,
          "','",
          Module1.newModule.end1,
          "','",
          Module1.newModule.Pin,
          "','",
          Module1.newModule.Term,
          "','",
          Module1.newModule.wireno1,
          "','",
          Module1.newModule.end2,
          "','",
          Module1.newModule.pin2,
          "','",
          Module1.newModule.term2,
          "',' ",
          Module1.newModule.WireSpec,
          "','",
          Module1.newModule.ACTION,
          "')"
        });
                data3.ExecuteSQL(str2);
                row = null;
                i += 1;
            }
            set2 = data2.getData(("select * from tblwires WHERE WIRESPLID = '" + Module1.newModule.PlanNumber + "' AND SREFDES NOT LIKE '%J%' order by SREFDES,WIRENO"));
            int num6 = (set2.Tables[0].Rows.Count - 1);
            int j = 0;
            while ((j <= num6))
            {
                int num4 = new int();//JMR -- look at -- changed int num4 to int num4 = new int();
                DataRow row2 = set2.Tables[0].Rows[j];
                DataSet set4 = new DataSet();
                clsData data4 = new clsData();
                Module1.newModule.WireSpec = Conversions.ToString(row2[8]);
                str = Conversions.ToString(row2[9]);
                Module1.newModule.wireno1 = Conversions.ToString(row2[1]);
                Module1.newModule.end1 = Conversions.ToString(row2[7]);
                Module1.newModule.Pin = Conversions.ToString(row2[3]);
                Module1.newModule.Term = Conversions.ToString(row2[5]);
                Module1.newModule.ACTION = Conversions.ToString(row2[0]);
                if ((Module1.newModule.ACTION.StartsWith("ADD")))
                {
                    Module1.newModule.ACTION = " ADDED";
                    set4 = data4.getData(("SELECT REFDESID  FROM TBLREFDES WHERE REFDES = '" + Module1.newModule.end1 + "'"));
                    if ((set4.Tables[0].Rows.Count == 0))
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
              Module1.newModule.end1,
              "','',2,'",
              Module1.newModule.HARNESSID,
              "','",
              Module1.newModule.PlanNumber,
              "','Rework wires at  ",
              Module1.newModule.end1,
              " as follows and per 16PR145','','",
              Conversions.ToString(num4),
              "')"
            }));
                        str2 = string.Concat(new string[] {
              "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
              Module1.newModule.end1,
              "' AND REFPLANID ='",
              Module1.newModule.PlanNumber,
              "'"
            });
                        num4 = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                    }
                    else
                    {
                        num4 = Conversions.ToInteger(set4.Tables[0].Rows[0]["REFDESID"]);
                    }
                    set4 = data4.getData(string.Concat(new string[] {
            "select * from PTP where WIRE_NUMBER = '",
            Module1.newModule.wireno1,
            "' and ((WIRE_END_REF <> '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "') or (WIRE_END_REF = '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "')) AND PART_NUMBER ='",
            Module1.newModule.OldHarnessPTP,
            "'"
          }));
                    if ((set4.Tables[0].Rows.Count != 0))
                    {
                        Module1.newModule.end2 = Conversions.ToString(set4.Tables[0].Rows[0]["WIRE_END_REF"]);
                        Module1.newModule.pin2 = Conversions.ToString(set4.Tables[0].Rows[0]["WIRE_END_PIN"]);
                        Module1.newModule.term2 = Conversions.ToString(set4.Tables[0].Rows[0]["WIRE_END_PN"]);
                    }
                }
                else if ((Module1.newModule.ACTION == "REMOVE"))
                {
                    Module1.newModule.ACTION = "REMOVED";
                    set4 = data4.getData(("SELECT REFDESID FROM TBLREFDES WHERE REFDES = '" + Module1.newModule.end1 + "'"));
                    if ((set4.Tables[0].Rows.Count == 0))
                    {
                        data.ExecuteSQL(string.Concat(new string[] {
              "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
              Module1.newModule.end1,
              "','',2,'",
              Module1.newModule.HARNESSID,
              "','",
              Module1.newModule.PlanNumber,
              "','Rework wires at  ",
              Module1.newModule.end1,
              " as follows and per 16PR145','','",
              Module1.newModule.end1,
              "')"
            }));
                        str2 = string.Concat(new string[] {
              "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
              Module1.newModule.end1,
              "' AND REFPLANID ='",
              Module1.newModule.PlanNumber,
              "'"
            });
                        num4 = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                    }
                    else
                    {
                        num4 = Conversions.ToInteger(set4.Tables[0].Rows[0]["REFDESID"]);
                    }
                    set4 = data4.getData(string.Concat(new string[] {
            "select * from PTP where WIRE_NUMBER = '",
            Module1.newModule.wireno1,
            "' and ((WIRE_END_REF <> '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "') or (WIRE_END_REF = '",
            Module1.newModule.end1,
            "' and WIRE_END_PIN <> '",
            Module1.newModule.Pin,
            "')) AND PART_NUMBER ='",
            Module1.newModule.OldHarnessPTP,
            "'"
          }));
                    if ((set4.Tables[0].Rows.Count != 0))
                    {
                        Module1.newModule.end2 = Conversions.ToString(set4.Tables[0].Rows[0]["WIRE_END_REF"]);
                        Module1.newModule.pin2 = Conversions.ToString(set4.Tables[0].Rows[0]["WIRE_END_PIN"]);
                        Module1.newModule.term2 = Conversions.ToString(set4.Tables[0].Rows[0]["WIRE_END_PN"]);
                    }
                }
                str2 = "INSERT INTO tblBackShopWires";
                str2 = (str2 + "(bacPlid,bacREFDES1,bacPIN1,bacTerm1,bacWIRENO,bacREFDES2,bacPin2,bacTerm2,bacWIRESPEC,bacAction) values");
                str2 = string.Concat(new string[] {
          str2,
          "('",
          Module1.newModule.PlanNumber,
          "','",
          Module1.newModule.end1,
          "','",
          Module1.newModule.Pin,
          "','",
          Module1.newModule.Term,
          "','",
          Module1.newModule.wireno1,
          "','",
          Module1.newModule.end2,
          "','",
          Module1.newModule.pin2,
          "','",
          Module1.newModule.term2,
          "',' ",
          Module1.newModule.WireSpec,
          "','",
          Module1.newModule.ACTION,
          "')"
        });
                data4.ExecuteSQL(str2);
                row2 = null;
                j += 1;
            }
            Module1.newModule.HASCH = true;
            Module1.newModule.makewiresb = false;
        }

        private void  // ERROR: Handles clauses are not supported in C#
    frmHarness_Disposed(object sender, System.EventArgs e)
        {
            try
            {
                // UpdateThread.Suspend()
            }
            catch (Exception exception1)
            {

                Exception exception = exception1;

            }
        }

        public void DataBindToDataGrid()
        {
            this.dsql2 = dsql.Copy();
        }
        private void  // ERROR: Handles clauses are not supported in C#
    frmHarness_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
        {
            Module1.newModule.FormCloseex = this.FormCloseex2;
            clsData data = new clsData();
            if ((!Module1.newModule.BAckhrn && Module1.newModule.FormCloseex))
            {
                data.ExecuteSQL(("DELETE * FROM TBLGENERAL WHERE genPlId = '" + Module1.newModule.PlanNumber + "'"));
                data.ExecuteSQL(("DELETE * FROM TBLPLANO WHERE PlannoId = '" + Module1.newModule.PlanNumber + "'"));
                data.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblEcn set  comment ='",
          Module1.newModule.ProgramId,
          " 'where ECN = '",
          Module1.newModule.stath,
          "' and rcn = '",
          Module1.newModule.EFFECTIVITIES,
          "' AND DASH ='",
          Module1.newModule.DRWREV,
          "'"
        }));
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    frmHarness_Load(object sender, System.EventArgs e)
        {
            DataSet aset = new DataSet();
            clsData data2 = new clsData();
            clsData data = new clsData();

            data2.ExecuteSQL("DELETE * FROM PTP2");
            data2.ExecuteSQL("DELETE * FROM CBE2");
            Module1.newModule.Createadapter(this.dsPtp, "PTP2", ("*"), ref daPTP2);
            Module1.newModule.Createadapter(this.dsPtp, "CBE2", ("*"), ref daCBE2);
            Module1.newModule.PlanNumber = Module1.newModule.plnumber;
            if (Module1.newModule.BAckhrn)
            {
                this.FormCloseex2 = false;
                aset = data2.getData(("select DISTINCT PART_NUMBER,DWG from PTP WHERE DWG like'" + Module1.newModule.DrwNo + "'"));
                if ((aset.Tables[0].Rows.Count == 0))
                {
                    XtraMessageBox.Show("No harness data found in database!");
                    this.Close();
                }
                else
                {
                    this.grdHarnSel.DataSource = aset.Tables[0];
                    this.grdHarnSel.Refresh();
                    Module1.newModule.oldSel = false;
                }
            }
            else
            {
                aset = data2.getData(("select DISTINCT PART_NUMBER,DWG from PTP where DWG ='" + Module1.newModule.DrwNo + "'"));
                if ((aset.Tables[0].Rows.Count == 0))
                {
                    XtraMessageBox.Show("No harness data found in database!");
                    data.ExecuteSQL(string.Concat(new string[] {
            "UPDATE tblEcn set  comment ='",
            Module1.newModule.ProgramId,
            " 'where ECN = '",
            Module1.newModule.stath,
            "' and rcn = '",
            Module1.newModule.EFFECTIVITIES,
            "' AND DASH ='",
            Module1.newModule.DRWREV,
            "'"
          }));
                    this.Close();
                }
                else
                {
                    this.grdHarnSel.DataSource = aset.Tables[0];
                    this.grdHarnSel.Refresh();
                    Module1.newModule.oldSel = false;
                }
            }
        }


        private void  // ERROR: Handles clauses are not supported in C#
    viewHarnSel_DoubleClick(object sender, System.EventArgs e)
        {

            DataSet aset = new DataSet();
            clsData data = new clsData();
            Module1.newModule.ISRUNN = false;
            var thirteen = char.ConvertFromUtf32((int)13); //changed from ChrW(13)    JMR
            var ten = char.ConvertFromUtf32((int)10); //changed from ChrW(10)         JMR
            if (!(Module1.newModule.ISRUNN | Module1.newModule.makewiresb))
            {
                string plnumber;
                if (Module1.newModule.BAckhrn)
                {
                    plnumber = Module1.newModule.plnumber;
                }
                else
                {
                    plnumber = Module1.newModule.plnumber;
                }
                Module1.newModule.HARNESSID = Guid.NewGuid().ToString();
                if (!Module1.newModule.oldSel)
                {
                    Module1.newModule.oldSel = true;
                    Module1.newModule.OldHarnessPTP = Conversions.ToString(viewHarnSel.GetRowCellValue(this.viewHarnSel.GetSelectedRows()[0], "PART_NUMBER"));
                    Module1.newModule.OldDRW = Conversions.ToString(viewHarnSel.GetRowCellValue(this.viewHarnSel.GetSelectedRows()[0], "DWG"));
                    txtOldHarnessPTP.Text = Module1.newModule.OldHarnessPTP;
                    Module1.newModule.oldharn = Module1.newModule.OldHarnessPTP;
                    XtraMessageBox.Show(" Old Harness selected." + thirteen + ten + "Select now new Harness.", "Select Harness", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    Module1.newModule.NewHarnessPTP = Conversions.ToString(viewHarnSel.GetRowCellValue(viewHarnSel.GetSelectedRows()[0], "PART_NUMBER"));
                    Module1.newModule.newharn = Module1.newModule.NewHarnessPTP;
                    Module1.newModule.NewDWG = Conversions.ToString(this.viewHarnSel.GetRowCellValue(this.viewHarnSel.GetSelectedRows()[0], "DWG"));
                    txtNewHarnesPTP.Text = Module1.newModule.NewHarnessPTP;
                    if ((Module1.newModule.OldDRW == Module1.newModule.NewDWG))
                    {

                    }
                    else
                    {
                        DialogResult ans2;
                        ans2 = XtraMessageBox.Show("Different harness selected click Yes to continue", "Comparison", MessageBoxButtons.YesNo);
                        //JMR -- look at -- took Windows.Forms. off Windows.Forms.DialogResult.No
                        if (ans2 == DialogResult.No)
                        {

                            this.txtNewHarnesPTP.Text = "";
                            this.txtOldHarnessPTP.Text = "";
                            Module1.newModule.oldSel = false;
                            return;
                        }
                    }
                    DialogResult result;
                    if ((Module1.newModule.OldHarnessPTP == Module1.newModule.NewHarnessPTP))
                    {
                        Module1.newModule.OldHarnessPTP = (Module1.newModule.NewHarnessPTP + "99");
                        Module1.newModule.oldharn = Module1.newModule.OldHarnessPTP;
                        result = XtraMessageBox.Show(("Do you want to create new harness " + Module1.newModule.NewHarnessPTP + " ."), "Confirm selection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }
                    else
                    {
                        result = XtraMessageBox.Show(("You select " + Module1.newModule.OldHarnessPTP + " to be reworked to " + Module1.newModule.NewHarnessPTP), "Confirm selection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }
                    if ((result == DialogResult.Yes))
                    {
                        string str2;
                        clsData data2 = new clsData();
                        Module1.newModule.oldSel = false;
                        Application.DoEvents();
                        try
                        {
                            data.ExecuteSQL("UPDATE PTP SET WIRE_END_PIN ='-' WHERE WIRE_END_PIN IS NULL ");
                            data.ExecuteSQL("UPDATE PTP SET WIRE_END_PN ='-' WHERE WIRE_END_PN IS NULL ");
                        }
                        catch (Exception exception1)
                        {

                            Exception exception = exception1;

                        }
                        if (Module1.newModule.BAckhrn)
                        {
                            data.ExecuteSQL(("DELETE * FROM PDFWIRE1 WHERE pdfplid1 = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM PDFWIRE2 WHERE pdfplid2 = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLBACKSHOPWIRES WHERE bacPlId = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLCONT WHERE bacPlId = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLMISC WHERE MISCPLANID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%WT%' and RefPlanId = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLREFDESCOMP WHERE REFCOMPPLID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%OLD%' and RefPlanId = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLREFDES WHERE REFDES like '%GD%' and RefPlanId = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLROUTE WHERE  rPlId= '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLWIRES WHERE WIRESPLID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLWIRESREMOVE WHERE WIRESPLID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLWIRESADD WHERE WIRESPLID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLWIRESREVISE WHERE WIRESPLID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM tblWiresBackshell WHERE WIRESPLID = '" + plnumber + "'"));
                            data.ExecuteSQL(("DELETE * FROM TBLSELHARNESS WHERE hrnSelPlId = '" + plnumber + "'"));
                            data.ExecuteSQL(("UPDATE TBLREFDES SET OPN ='2' WHERE RefPlanId ='" + plnumber + "'"));
                            data2.ExecuteSQL(string.Concat(new string[] {
                "INSERT INTO TBLSELHARNESS (hrnSelPlId,OLDHRN,NEWHRN) VALUES ('",
                plnumber,
                "','",
                Module1.newModule.OldHarnessPTP,
                "','",
                Module1.newModule.NewHarnessPTP,
                "')"
              }));
                            try
                            {
                                pr1.Properties.Maximum = 100;
                                pr1.EditValue = 0;
                                pr1.Update();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing removed wires....";
                                updatethread = new Thread(QueryDataBase);
                                updatethread.IsBackground = true;
                                updatethread.Name = "UpdateThread";
                                updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                this.mr2.Visible = false;
                                this.pr1.EditValue = 100;
                                this.pr1.Update();
                            }
                            catch (Exception exception4)
                            {

                                Exception exception2 = exception4;
                                //f  XtraMessageBox.Show(exception2.Message)

                            }
                            aset = dsql.Copy();
                            this.pr1.Properties.ShowTitle = true;
                            int num9 = (aset.Tables[0].Rows.Count - 1);
                            int i = 0;
                            while ((i <= num9))
                            {
                                this.pr1.Properties.Minimum = 1;
                                this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                this.pr1.Text = "Saving data please wait ....";
                                this.pr1.EditValue = (i + 1);
                                this.pr1.Update();
                                DataRow row = aset.Tables[0].Rows[i];
                                string source = Conversions.ToString(row[7]);
                                string str9 = Conversions.ToString(row[4]);
                                string str8 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row[8])));
                                string str3 = "REMOVE";
                                string str7 = Conversions.ToString(row[10]);
                                string str5 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row[9])));
                                if (((str5.Contains("STRIP") & source.EndsWith("A")) && !str9.Contains("SH")))
                                {
                                    str5 = "16VE049012-1";
                                }
                                if (((str5.Contains("STRIP") & source.EndsWith("B")) && !str9.Contains("SH")))
                                {
                                    str5 = "16VE049012-1";
                                }
                                Module1.newModule.EndPoint = Conversions.ToString(row[6]);
                                if ((((LikeOperator.LikeString(source, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(source, "*77#[A-Z]*", CompareMethod.Binary)) | LikeOperator.LikeString(source, "*73#[A-Z]", CompareMethod.Binary)) && !LikeOperator.LikeString(str9, "*SH*", CompareMethod.Binary)))
                                {
                                    Module1.newModule.wireno1 = str9;
                                    DataSet set3 = new DataSet();
                                    set3 = data.getData(string.Concat(new string[] {
                    "SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESREMOVE WHERE WIRENO ='",
                    Module1.newModule.wireno1,
                    "' and WIRESPLID ='",
                    plnumber,
                    "'"
                  }));
                                    if ((set3.Tables[0].Rows.Count != 0))
                                    {
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(set3.Tables[0].Rows[0]["WREFDESID"]);
                                        Module1.newModule.sRefDes = Conversions.ToString(set3.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.REFDES1 = source;
                                    }
                                }
                                if ((((LikeOperator.LikeString(source, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(source, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str9, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == source)))
                                {
                                    if (Module1.newModule.BAckhrn)
                                    {
                                        Module1.newModule.BAckhrn = false;
                                    }
                                    if (Module1.newModule.sRefDes.Contains("WT") && str9.Contains("SH"))
                                    {
                                        DataSet dsf = new DataSet();
                                        dsf = data.getData("SELECT * FROM TBLWIRES WHERE WIRENO LIKE '" + str9.Substring(0, str9.Length - 5) + "%' AND ENDPOINT ='" + Module1.newModule.EndPoint + "' AND WIRESPLID ='" + plnumber + "'");
                                        Module1.newModule.sRefDes = Conversions.ToString(dsf.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(dsf.Tables[0].Rows[0][2]);

                                    }
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET PIN = '",
                    source,
                    "' ,SWIRENO ='",
                    str9,
                    "Z' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    source,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESREMOVE SET PIN = '",
                    source,
                    "' ,SWIRENO ='",
                    str9,
                    "Z' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    source,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET SWIRENO ='",
                    str9,
                    "ZZ' WHERE WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESREMOVE SET SWIRENO ='",
                    str9,
                    "ZZ' WHERE WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str3,
                    "','",
                    str9,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    source,
                    "','",
                    str7,
                    "','",
                    str5,
                    "','",
                    str9,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresREMOVE ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str3,
                    "','",
                    str9,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    source,
                    "','",
                    str7,
                    "','",
                    str5,
                    "','",
                    str9,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                else
                                {
                                    string str4;
                                    if (LikeOperator.LikeString(source, "*WT*", CompareMethod.Binary))
                                    {
                                        str4 = "wire tie";
                                    }
                                    else
                                    {
                                        str4 = "connector";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    source,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    DataSet set2 = data.getData(str2);
                                    if ((set2.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      source,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str4,
                      " ",
                      source,
                      " as follows and per 16PR145','','",
                      source,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      source,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set2.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str3,
                    "','",
                    str9,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str8,
                    "','",
                    str7,
                    "','",
                    str5,
                    "','",
                    str9,
                    "','",
                    source,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresREMOVE ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str3,
                    "','",
                    str9,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str8,
                    "','",
                    str7,
                    "','",
                    str5,
                    "','",
                    str9,
                    "','",
                    source,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                row = null;
                                i += 1;
                            }
                            this.pr1.Properties.Maximum = 100;
                            this.pr1.EditValue = 0x23;
                            this.pr1.Update();
                            Application.DoEvents();
                            Cursor.Current = Cursors.WaitCursor;
                            this.mr2.Visible = true;
                            this.mr2.Properties.ShowTitle = true;
                            this.mr2.Text = "Comparing added wires....";
                            updatethread = new Thread(QueryDataBase2);
                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();
                            Module1.newModule.ISRUNN = true;
                            do
                            {
                                Application.DoEvents();
                            } while (Module1.newModule.ISRUNN);
                            Application.DoEvents();
                            this.mr2.Visible = false;
                            aset = dsql.Copy();
                            this.pr1.Properties.ShowTitle = true;
                            this.pr1.Text = "Saving data please wait ....";
                            int num10 = (aset.Tables[0].Rows.Count - 1);
                            int j = 0;
                            while ((j <= num10))
                            {
                                this.pr1.Properties.Minimum = 1;
                                this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                this.pr1.EditValue = (j + 1);
                                this.pr1.Update();
                                DataRow row2 = aset.Tables[0].Rows[j];
                                string str12 = Conversions.ToString(row2[7]);
                                string str14 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row2[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row2[8])));
                                string str10 = "ADD";
                                string str15 = Conversions.ToString(row2[4]);
                                string str13 = Conversions.ToString(row2[10]);
                                string str11 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row2[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row2[9])));
                                Module1.newModule.EndPoint = Conversions.ToString(row2[6]);
                                if (((str11.Contains("STRIP") & str12.EndsWith("A")) && !str15.Contains("SH")))
                                {
                                    str11 = "16VE049012-1";
                                }
                                if (((str11.Contains("STRIP") & str12.EndsWith("B")) && !str15.Contains("SH")))
                                {
                                    str11 = "16VE049012-1";
                                }
                                if (((LikeOperator.LikeString(str12, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str12, "*77#[A-Z]*", CompareMethod.Binary)) && !LikeOperator.LikeString(str15, "*SH*", CompareMethod.Binary)))
                                {
                                    Module1.newModule.wireno1 = str15;
                                    DataSet set5 = new DataSet();
                                    set5 = data.getData(string.Concat(new string[] {
                    "SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESADD WHERE WIRENO ='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID ='",
                    plnumber,
                    "'"
                  }));
                                    if ((set5.Tables[0].Rows.Count != 0))
                                    {
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(set5.Tables[0].Rows[0]["WREFDESID"]);
                                        Module1.newModule.sRefDes = Conversions.ToString(set5.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.REFDES1 = str12;
                                    }
                                }
                                if ((((LikeOperator.LikeString(str12, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str12, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str15, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == str12)))
                                {
                                    if (Module1.newModule.BAckhrn)
                                    {
                                        Module1.newModule.BAckhrn = false;
                                    }
                                    if (Module1.newModule.sRefDes.Contains("WT") && str15.Contains("SH"))
                                    {
                                        DataSet dsf = new DataSet();
                                        dsf = data.getData("SELECT * FROM TBLWIRES WHERE WIRENO LIKE '" + str15.Substring(0, str15.Length - 5) + "%' AND ENDPOINT ='" + Module1.newModule.EndPoint + "' AND WIRESPLID ='" + plnumber + "'");
                                        Module1.newModule.sRefDes = Conversions.ToString(dsf.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(dsf.Tables[0].Rows[0][2]);

                                    }
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET PIN = '",
                    str12,
                    "' ,SWIRENO ='",
                    str15,
                    "Z' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    str12,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESADD SET PIN = '",
                    str12,
                    "' ,SWIRENO ='",
                    str15,
                    "Z' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    str12,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET SWIRENO ='",
                    str15,
                    "ZZ' WHERE SWIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESADD SET SWIRENO ='",
                    str15,
                    "ZZ' WHERE SWIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str10,
                    "','",
                    str15,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    str12,
                    "','",
                    str13,
                    "','",
                    str11,
                    "','",
                    str15,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresADD ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str10,
                    "','",
                    str15,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    str12,
                    "','",
                    str13,
                    "','",
                    str11,
                    "','",
                    str15,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                else
                                {
                                    string str16;
                                    if (LikeOperator.LikeString(str12, "*WT*", CompareMethod.Binary))
                                    {
                                        str16 = "wire tie";
                                    }
                                    else
                                    {
                                        str16 = "connector";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str12,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    DataSet set4 = data.getData(str2);
                                    if ((set4.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str12,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str16,
                      " ",
                      str12,
                      " as follows and per 16PR145','','",
                      str12,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str12,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set4.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str10,
                    "','",
                    str15,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str14,
                    "','",
                    str13,
                    "','",
                    str11,
                    "','",
                    str15,
                    "','",
                    str12,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresADD ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str10,
                    "','",
                    str15,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str14,
                    "','",
                    str13,
                    "','",
                    str11,
                    "','",
                    str15,
                    "','",
                    str12,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                row2 = null;
                                j += 1;
                            }
                            this.pr1.Properties.Maximum = 100;
                            this.pr1.Update();
                            Application.DoEvents();
                            Cursor.Current = Cursors.WaitCursor;
                            this.mr2.Visible = true;
                            this.mr2.Properties.ShowTitle = true;
                            this.mr2.Text = "Comparing removed parts....";
                            updatethread = new Thread(QueryDataBase3);
                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();
                            Module1.newModule.ISRUNN = true;
                            do
                            {
                                Application.DoEvents();
                            } while (Module1.newModule.ISRUNN);
                            this.mr2.Visible = false;
                            this.pr1.Properties.ShowTitle = true;
                            this.pr1.Text = "Saving data please wait ....";
                            aset = dsql.Copy();
                            int num11 = (aset.Tables[0].Rows.Count - 1);
                            int k = 0;
                            while ((k <= num11))
                            {
                                string str18;
                                this.pr1.Properties.Minimum = 1;
                                this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                this.pr1.EditValue = (k + 1);
                                this.pr1.Update();
                                DataRow row3 = aset.Tables[0].Rows[k];
                                DataSet set6 = new DataSet();
                                string str21 = Conversions.ToString(row3[4]);
                                string str19 = Conversions.ToString(row3[5]);
                                string str17 = Conversions.ToString(row3[8]);
                                string str20 = Conversions.ToString(row3[7]);
                                if (LikeOperator.LikeString(str21, "%WT%", CompareMethod.Binary))
                                {
                                    str18 = "wire tie";
                                }
                                else
                                {
                                    str18 = "connector";
                                }
                                str2 = string.Concat(new string[] {
                  "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                  str21,
                  "' AND REFPLANID ='",
                  plnumber,
                  "'"
                });
                                set6 = data.getData(str2);
                                if ((set6.Tables[0].Rows.Count == 0))
                                {
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                    str21,
                    "','',2,'",
                    Module1.newModule.HARNESSID,
                    "','",
                    plnumber,
                    "','Rework wires at ",
                    str18,
                    " ",
                    str21,
                    " as follows and per 16PR145','','",
                    str21,
                    "')"
                  }));
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str21,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                }
                                else
                                {
                                    Module1.newModule.RefDesId = Conversions.ToInteger(set6.Tables[0].Rows[0]["REFDESID"]);
                                }
                                str2 = "INSERT INTO tblREFDESCOMP";
                                str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                str2 = string.Concat(new string[] {
                  str2,
                  "('",
                  str19,
                  "','",
                  str17,
                  "','",
                  str20,
                  "','REMOVE','",
                  str21,
                  "','",
                  Module1.newModule.HARNESSID,
                  "','",
                  plnumber,
                  "',",
                  Conversions.ToString(Module1.newModule.RefDesId),
                  ")"
                });
                                data.ExecuteSQL(str2);
                                row3 = null;
                                k += 1;
                            }
                            this.pr1.Properties.Maximum = 100;
                            this.pr1.EditValue = 0x23;
                            this.pr1.Update();
                            Application.DoEvents();
                            Cursor.Current = Cursors.WaitCursor;
                            this.mr2.Visible = true;
                            this.mr2.Properties.ShowTitle = true;
                            this.mr2.Text = "Comparing added parts....";
                            updatethread = new Thread(QueryDataBase4);
                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();
                            Module1.newModule.ISRUNN = true;
                            do
                            {
                                Application.DoEvents();
                            } while (Module1.newModule.ISRUNN);
                            this.mr2.Visible = false;
                            aset = dsql.Copy();
                            this.pr1.Properties.ShowTitle = true;
                            this.pr1.Text = "Saving data please wait ....";
                            if ((aset != null))
                            {
                                int num12 = (aset.Tables[0].Rows.Count - 1);
                                int m = 0;
                                while ((m <= num12))
                                {
                                    string str23;
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (m + 1);
                                    this.pr1.Update();
                                    DataRow row4 = aset.Tables[0].Rows[m];
                                    string str26 = Conversions.ToString(row4[4]);
                                    string str24 = Conversions.ToString(row4[5]);
                                    string str22 = Conversions.ToString(row4[8]);
                                    string str25 = Conversions.ToString(row4[7]);
                                    if (LikeOperator.LikeString(str26, "%WT%", CompareMethod.Binary))
                                    {
                                        str23 = "wire tie";
                                    }
                                    else
                                    {
                                        str23 = "";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str26,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    DataSet set7 = data.getData(str2);
                                    if ((set7.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str26,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str23,
                      " ",
                      str26,
                      " as follows and per 16PR145','','",
                      str26,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str26,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set7.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblREFDESCOMP";
                                    str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str24,
                    "','",
                    str22,
                    "','",
                    str25,
                    "','ADD','",
                    str26,
                    "','",
                    Module1.newModule.HARNESSID,
                    "','",
                    plnumber,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ")"
                  });
                                    data.ExecuteSQL(str2);
                                    row4 = null;
                                    m += 1;
                                }
                            }
                        }
                        else
                        {
                            Module1.newModule.dashl = Module1.newModule.DrwNo.Length;
                            Module1.newModule.oldval = Conversions.ToInteger(Module1.newModule.OldHarnessPTP.Substring((Module1.newModule.dashl + 1), (Module1.newModule.OldHarnessPTP.Length - (Module1.newModule.dashl + 1))));
                            Module1.newModule.newval = Conversions.ToInteger(Module1.newModule.NewHarnessPTP.Substring((Module1.newModule.dashl + 1), (Module1.newModule.NewHarnessPTP.Length - (Module1.newModule.dashl + 1))));
                            try
                            {
                                this.pr1.Properties.Maximum = 100;
                                this.pr1.EditValue = 0x23;
                                this.pr1.Update();
                                Cursor.Current = Cursors.WaitCursor;
                                this.mr2.Visible = true;
                                this.mr2.Properties.ShowTitle = true;
                                this.mr2.Text = "Comparing removed wires....";
                                updatethread = new Thread(QueryDataBase);
                                updatethread.IsBackground = true;
                                updatethread.Name = "UpdateThread";
                                updatethread.Start();
                                Module1.newModule.ISRUNN = true;
                                do
                                {
                                    Application.DoEvents();
                                } while (Module1.newModule.ISRUNN);
                                this.mr2.Visible = false;
                                aset = dsql.Copy();
                                this.pr1.Properties.ShowTitle = true;
                                this.pr1.Text = "Saving data please wait ....";
                                this.pr1.EditValue = 100;
                                this.pr1.Update();
                            }
                            catch (Exception exception5)
                            {
                                ProjectData.SetProjectError(exception5);
                                Exception exception3 = exception5;

                                ProjectData.ClearProjectError();
                            }
                            int num13 = (aset.Tables[0].Rows.Count - 1);
                            int n = 0;
                            while ((n <= num13))
                            {
                                this.pr1.Properties.Minimum = 1;
                                this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                this.pr1.EditValue = (n + 1);
                                this.pr1.Update();
                                DataRow row5 = aset.Tables[0].Rows[n];
                                string str30 = Conversions.ToString(row5[7]);
                                string str33 = Conversions.ToString(row5[4]);
                                if (str33.Contains("201"))
                                {
                                    string p;
                                    p = "gf";

                                }
                                if (str33.Contains("31"))
                                {
                                    string p;
                                    p = "gf";

                                }
                                string str32 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row5[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row5[8])));
                                string str27 = "REMOVE";
                                string str31 = Conversions.ToString(row5[10]);
                                string str29 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row5[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row5[9])));
                                if (((str29.Contains("STRIP") & str30.EndsWith("A")) && !str33.Contains("SH")))
                                {
                                    str29 = "16VE049012-1";
                                }
                                if (((str29.Contains("STRIP") & str30.EndsWith("B")) && !str33.Contains("SH")))
                                {
                                    str29 = "16VE049012-1";
                                }
                                Module1.newModule.EndPoint = Conversions.ToString(row5[6]);
                                if ((((LikeOperator.LikeString(str30, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str30, "*77#[A-Z]*", CompareMethod.Binary)) | LikeOperator.LikeString(str30, "*73#[A-Z]", CompareMethod.Binary)) && !LikeOperator.LikeString(str33, "*SH*", CompareMethod.Binary)))
                                {
                                    Module1.newModule.wireno1 = str33;
                                    DataSet set9 = new DataSet();

                                    set9 = data.getData(string.Concat(new string[] {
                    "SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESREMOVE WHERE WIRENO ='",
                    Module1.newModule.wireno1,
                    "' and WIRESPLID ='",
                    plnumber,
                    "'"
                  }));
                                    if ((set9.Tables[0].Rows.Count != 0))
                                    {
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(set9.Tables[0].Rows[0]["WREFDESID"]);
                                        Module1.newModule.sRefDes = Conversions.ToString(set9.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.REFDES1 = str30;
                                    }
                                }
                                if ((((LikeOperator.LikeString(str30, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str30, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str33, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == str30)))
                                {
                                    if (Module1.newModule.BAckhrn)
                                    {
                                        Module1.newModule.BAckhrn = false;
                                    }
                                    if (Module1.newModule.sRefDes.Contains("WT") && str33.Contains("SH"))
                                    {
                                        DataSet dsf = new DataSet();
                                        dsf = data.getData("SELECT * FROM TBLWIRES WHERE WIRENO LIKE '" + str33.Substring(0, str33.Length - 5) + "%' AND ENDPOINT ='" + Module1.newModule.EndPoint + "' AND WIRESPLID ='" + plnumber + "'");
                                        Module1.newModule.sRefDes = Conversions.ToString(dsf.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(dsf.Tables[0].Rows[0][2]);

                                    }
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET PIN = '",
                    str30,
                    "' ,SWIRENO ='",
                    str33,
                    "Zz' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    str30,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESREMOVE SET PIN = '",
                    str30,
                    "' ,SWIRENO ='",
                    str33,
                    "Zz' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    str30,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET SWIRENO ='",
                    str33,
                    "Z' WHERE WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESREMOVE SET SWIRENO ='",
                    str33,
                    "Z' WHERE WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str27,
                    "','",
                    str33,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    str30,
                    "','",
                    str31,
                    "','",
                    str29,
                    "','",
                    str33,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresREMOVE ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str27,
                    "','",
                    str33,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    str30,
                    "','",
                    str31,
                    "','",
                    str29,
                    "','",
                    str33,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                else
                                {
                                    string str28;
                                    if (LikeOperator.LikeString(str30, "*WT*", CompareMethod.Binary))
                                    {
                                        str28 = "wire tie";
                                    }
                                    else
                                    {
                                        str28 = "connector";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str30,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    DataSet set8 = data.getData(str2);
                                    if ((set8.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str30,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str28,
                      " ",
                      str30,
                      " as follows and per 16PR145','','",
                      str30,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str30,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set8.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str27,
                    "','",
                    str33,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str32,
                    "','",
                    str31,
                    "','",
                    str29,
                    "','",
                    str33,
                    "','",
                    str30,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresREMOVE ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str27,
                    "','",
                    str33,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str32,
                    "','",
                    str31,
                    "','",
                    str29,
                    "','",
                    str33,
                    "','",
                    str30,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                row5 = null;
                                n += 1;
                            }
                            this.pr1.Properties.Maximum = 100;
                            this.pr1.EditValue = 0x23;
                            this.pr1.Update();
                            Application.DoEvents();
                            Cursor.Current = Cursors.WaitCursor;
                            this.mr2.Visible = true;
                            this.mr2.Properties.ShowTitle = true;
                            this.mr2.Text = "Comparing added wires....";
                            updatethread = new Thread(QueryDataBase2);
                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();
                            Module1.newModule.ISRUNN = true;
                            do
                            {
                                Application.DoEvents();
                            } while (Module1.newModule.ISRUNN);
                            this.mr2.Visible = false;
                            this.pr1.Properties.ShowTitle = true;
                            this.pr1.Text = "Saving data please wait ....";
                            aset = dsql.Copy();
                            int num14 = (aset.Tables[0].Rows.Count - 1);
                            int num6 = 0;
                            while ((num6 <= num14))
                            {
                                this.pr1.Properties.Minimum = 1;
                                this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                this.pr1.EditValue = (num6 + 1);
                                this.pr1.Update();
                                DataRow row6 = aset.Tables[0].Rows[num6];
                                string str36 = Conversions.ToString(row6[7]);
                                string str38 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row6[8], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row6[8])));
                                string str34 = "ADD";
                                string str39 = Conversions.ToString(row6[4]);
                                string str37 = Conversions.ToString(row6[10]);
                                string str35 = Conversions.ToString(Interaction.IIf((object.ReferenceEquals(row6[9], DBNull.Value)), "-", RuntimeHelpers.GetObjectValue(row6[9])));
                                Module1.newModule.EndPoint = Conversions.ToString(row6[6]);
                                if (((str35.Contains("STRIP") & str36.EndsWith("A")) && !str39.Contains("SH")))
                                {
                                    str35 = "16VE049012-1";
                                }
                                if (((str35.Contains("STRIP") & str36.EndsWith("B")) && !str39.Contains("SH")))
                                {
                                    str35 = "16VE049012-1";
                                }
                                if (((LikeOperator.LikeString(str36, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str36, "*77#[A-Z]*", CompareMethod.Binary)) && !LikeOperator.LikeString(str39, "*SH*", CompareMethod.Binary)))
                                {
                                    Module1.newModule.wireno1 = str39;
                                    DataSet set11 = new DataSet();
                                    set11 = data.getData(string.Concat(new string[] {
                    "SELECT SREFDES AS SREFDES,WREFDESID AS WREFDESID FROM TBLWIRESADD WHERE WIRENO ='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID ='",
                    plnumber,
                    "'"
                  }));
                                    if ((set11.Tables[0].Rows.Count != 0))
                                    {
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(set11.Tables[0].Rows[0]["WREFDESID"]);
                                        Module1.newModule.sRefDes = Conversions.ToString(set11.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.REFDES1 = str36;
                                    }
                                }
                                if ((((LikeOperator.LikeString(str36, "*S77*", CompareMethod.Binary) | LikeOperator.LikeString(str36, "*77#[A-Z]*", CompareMethod.Binary)) && LikeOperator.LikeString(str39, "*SH*", CompareMethod.Binary)) && (Module1.newModule.REFDES1 == str36)))
                                {
                                    if (Module1.newModule.BAckhrn)
                                    {
                                        Module1.newModule.BAckhrn = false;
                                    }
                                    if (Module1.newModule.sRefDes.Contains("WT") && str36.Contains("SH"))
                                    {
                                        DataSet dsf = new DataSet();
                                        dsf = data.getData("SELECT * FROM TBLWIRES WHERE WIRENO LIKE '" + str36.Substring(0, str36.Length - 5) + "%' AND ENDPOINT ='" + Module1.newModule.EndPoint + "' AND WIRESPLID ='" + plnumber + "'");
                                        Module1.newModule.sRefDes = Conversions.ToString(dsf.Tables[0].Rows[0]["SREFDES"]);
                                        Module1.newModule.refdesidnew = Conversions.ToInteger(dsf.Tables[0].Rows[0][2]);

                                    }
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET PIN = '",
                    str36,
                    "' ,SWIRENO ='",
                    str39,
                    "Z' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    str36,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESADD SET PIN = '",
                    str36,
                    "' ,SWIRENO ='",
                    str39,
                    "Z' , WREFDESID = ",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    " ,SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' WHERE SREFDES ='",
                    str36,
                    "' AND WIRENO='",
                    Module1.newModule.wireno1,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRES SET SWIRENO ='",
                    str39,
                    "ZZ' WHERE SWIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "UPDATE TBLWIRESADD SET SWIRENO ='",
                    str39,
                    "ZZ' WHERE SWIRENO='",
                    Module1.newModule.wireno1,
                    "' AND SREFDES ='",
                    Module1.newModule.sRefDes,
                    "' AND WIRESPLID = '",
                    plnumber,
                    "'"
                  }));
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str34,
                    "','",
                    str39,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    str36,
                    "','",
                    str37,
                    "','",
                    str35,
                    "','",
                    str39,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresADD ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str34,
                    "','",
                    str39,
                    "',",
                    Conversions.ToString(Module1.newModule.refdesidnew),
                    ",'",
                    str36,
                    "','",
                    str37,
                    "','",
                    str35,
                    "','",
                    str39,
                    "','",
                    Module1.newModule.sRefDes,
                    "','','",
                    plnumber,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                else
                                {
                                    string str40;
                                    if (LikeOperator.LikeString(str36, "*WT*", CompareMethod.Binary))
                                    {
                                        str40 = "wire tie";
                                    }
                                    else
                                    {
                                        str40 = "connector";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str36,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    DataSet set10 = data.getData(str2);
                                    if ((set10.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str36,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str40,
                      " ",
                      str36,
                      " as follows and per 16PR145','','",
                      str36,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str36,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set10.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblWires ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str34,
                    "','",
                    str39,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str38,
                    "','",
                    str37,
                    "','",
                    str35,
                    "','",
                    str39,
                    "','",
                    str36,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                    str2 = "INSERT INTO tblWiresADD ";
                                    str2 = (str2 + "(WIREACTid,WIRENO,wREFDESid,PIN,LENGTH,TERM,SWIRENO,SREFDES,SHIELD,WIRESPLID,ENDPOINT) VALUES ");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str34,
                    "','",
                    str39,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ",'",
                    str38,
                    "','",
                    str37,
                    "','",
                    str35,
                    "','",
                    str39,
                    "','",
                    str36,
                    "','','",
                    plnumber,
                    "','",
                    Module1.newModule.EndPoint,
                    "')"
                  });
                                    data.ExecuteSQL(str2);
                                }
                                row6 = null;
                                num6 += 1;
                            }
                            this.pr1.Properties.Maximum = 100;
                            this.pr1.EditValue = 0x23;
                            this.pr1.Update();
                            Application.DoEvents();
                            Cursor.Current = Cursors.WaitCursor;
                            this.mr2.Visible = true;
                            this.mr2.Properties.ShowTitle = true;
                            this.mr2.Text = "Comparing removed parts....";
                            updatethread = new Thread(QueryDataBase3);

                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();
                            Module1.newModule.ISRUNN = true;
                            do
                            {
                                Application.DoEvents();
                            } while (Module1.newModule.ISRUNN);
                            this.mr2.Visible = false;
                            this.pr1.Properties.ShowTitle = true;
                            this.pr1.Text = "Saving data please wait ....";
                            aset = dsql.Copy();
                            int num15 = (aset.Tables[0].Rows.Count - 1);
                            int num7 = 0;
                            while ((num7 <= num15))
                            {
                                string str42;
                                this.pr1.Properties.Minimum = 1;
                                this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                this.pr1.EditValue = (num7 + 1);
                                this.pr1.Update();
                                DataRow row7 = aset.Tables[0].Rows[num7];
                                DataSet set12 = new DataSet();
                                string str45 = Conversions.ToString(row7[4]);
                                string str43 = Conversions.ToString(row7[5]);
                                string str41 = Conversions.ToString(row7[8]);
                                string str44 = Conversions.ToString(row7[7]);
                                if (LikeOperator.LikeString(str45, "%WT%", CompareMethod.Binary))
                                {
                                    str42 = "wire tie";
                                }
                                else
                                {
                                    str42 = "connector";
                                }
                                str2 = string.Concat(new string[] {
                  "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                  str45,
                  "' AND REFPLANID ='",
                  plnumber,
                  "'"
                });
                                set12 = data.getData(str2);
                                if ((set12.Tables[0].Rows.Count == 0))
                                {
                                    data.ExecuteSQL(string.Concat(new string[] {
                    "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                    str45,
                    "','',2,'",
                    Module1.newModule.HARNESSID,
                    "','",
                    plnumber,
                    "','Rework wires at ",
                    str42,
                    " ",
                    str45,
                    " as follows and per 16PR145','','",
                    str45,
                    "')"
                  }));
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str45,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                }
                                else
                                {
                                    Module1.newModule.RefDesId = Conversions.ToInteger(set12.Tables[0].Rows[0]["REFDESID"]);
                                }
                                str2 = "INSERT INTO tblREFDESCOMP";
                                str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                str2 = string.Concat(new string[] {
                  str2,
                  "('",
                  str43,
                  "','",
                  str41,
                  "','",
                  str44,
                  "','REMOVE','",
                  str45,
                  "','",
                  Module1.newModule.HARNESSID,
                  "','",
                  plnumber,
                  "',",
                  Conversions.ToString(Module1.newModule.RefDesId),
                  ")"
                });
                                data.ExecuteSQL(str2);
                                row7 = null;
                                num7 += 1;
                            }
                            this.pr1.Properties.Maximum = 100;
                            this.pr1.EditValue = 100;
                            this.pr1.Update();
                            Application.DoEvents();
                            Cursor.Current = Cursors.WaitCursor;
                            this.mr2.Visible = true;
                            this.mr2.Properties.ShowTitle = true;
                            this.mr2.Text = "Comparing added parts....";
                            updatethread = new Thread(QueryDataBase4);
                            this.updatethread.IsBackground = true;
                            this.updatethread.Name = "UpdateThread";
                            this.updatethread.Start();
                            Module1.newModule.ISRUNN = true;
                            do
                            {
                                Application.DoEvents();
                            } while (Module1.newModule.ISRUNN);
                            aset = dsql.Copy();
                            this.pr1.Properties.ShowTitle = true;
                            this.pr1.Text = "Saving data please wait ....";
                            this.mr2.Visible = false;
                            if ((aset != null))
                            {
                                int num16 = (aset.Tables[0].Rows.Count - 1);
                                int num8 = 0;
                                while ((num8 <= num16))
                                {
                                    string str47;
                                    this.pr1.Properties.Minimum = 1;
                                    this.pr1.Properties.Maximum = aset.Tables[0].Rows.Count;
                                    this.pr1.EditValue = (num8 + 1);
                                    this.pr1.Update();
                                    DataRow row8 = aset.Tables[0].Rows[num8];
                                    string str50 = Conversions.ToString(row8[4]);
                                    string str48 = Conversions.ToString(row8[5]);
                                    string str46 = Conversions.ToString(row8[8]);
                                    string str49 = Conversions.ToString(row8[7]);
                                    if (LikeOperator.LikeString(str50, "%WT%", CompareMethod.Binary))
                                    {
                                        str47 = "wire tie";
                                    }
                                    else
                                    {
                                        str47 = "";
                                    }
                                    str2 = string.Concat(new string[] {
                    "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                    str50,
                    "' AND REFPLANID ='",
                    plnumber,
                    "'"
                  });
                                    DataSet set13 = data.getData(str2);
                                    if ((set13.Tables[0].Rows.Count == 0))
                                    {
                                        data.ExecuteSQL(string.Concat(new string[] {
                      "INSERT INTO TBLREFDES (REFDES,REPORTNOTE,OPN,HARNESS,REFPLANID,REFWT,REFPREVIEW,BASEREF) VALUES ('",
                      str50,
                      "','',2,'",
                      Module1.newModule.HARNESSID,
                      "','",
                      plnumber,
                      "','Rework wires at ",
                      str47,
                      " ",
                      str50,
                      " as follows and per 16PR145','','",
                      str50,
                      "')"
                    }));
                                        str2 = string.Concat(new string[] {
                      "SELECT REFDESID AS REFDESID FROM TBLREFDES WHERE REFDES = '",
                      str50,
                      "' AND REFPLANID ='",
                      plnumber,
                      "'"
                    });
                                        Module1.newModule.RefDesId = Conversions.ToInteger(data.getData(str2).Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    else
                                    {
                                        Module1.newModule.RefDesId = Conversions.ToInteger(set13.Tables[0].Rows[0]["REFDESID"]);
                                    }
                                    str2 = "INSERT INTO tblREFDESCOMP";
                                    str2 = (str2 + "(PARTNUMBER,DESCRIPTION,QTY,REFACTION,LOCATION,HREFCOMPID,REFCOMPPLID,REFDESCOMID) VALUES");
                                    str2 = string.Concat(new string[] {
                    str2,
                    "('",
                    str48,
                    "','",
                    str46,
                    "','",
                    str49,
                    "','ADD','",
                    str50,
                    "','",
                    Module1.newModule.HARNESSID,
                    "','",
                    plnumber,
                    "',",
                    Conversions.ToString(Module1.newModule.RefDesId),
                    ")"
                  });
                                    data.ExecuteSQL(str2);
                                    row8 = null;
                                    num8 += 1;
                                }
                            }
                        }
                        //'Module1.makewiresb = True
                        //'updatethread = New Thread(AddressOf Me.MakeWires)
                        //'Me.updatethread.IsBackground = True
                        //'Me.updatethread.Name = "UpdateThread"
                        //'Me.updatethread.Start()
                        // '' Module1.ISRUNN = True

                        // ''     Thread(New ThreadStart(AddressOf MakeWires)) With { _
                        // ''        .IsBackground = True _
                        // ''    }.Start
                        //'Do
                        //'    Application.DoEvents()
                        //'    Me.mr2.Visible = True
                        //'    Me.mr2.Text = "Saving data please wait..."
                        //'Loop While Module1.makewiresb
                        //'aset = Nothing
                        Module1.newModule.HASCH = true;
                        this.FormCloseex2 = false;
                        this.pr1.EditValue = 100;
                        this.pr1.Update();
                        this.Close();
                    }
                    else
                    {
                        this.txtNewHarnesPTP.Text = "";
                        this.txtOldHarnessPTP.Text = "";
                        Module1.newModule.oldSel = false;
                    }

                }
            }

        }

        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton1_Click(System.Object sender, System.EventArgs e)
        {
            DataSet aset = new DataSet();
            clsData data2 = new clsData();
            clsData data = new clsData();
            Module1.newModule.DrwNo = "%%";
            aset = data2.getData(("select DISTINCT PART_NUMBER,DWG from PTP WHERE DWG like'" + Module1.newModule.DrwNo + "'"));
            if ((aset.Tables[0].Rows.Count == 0))
            {
                XtraMessageBox.Show("No harness data found in database!");
                this.Close();
            }
            else
            {
                this.grdHarnSel.DataSource = aset.Tables[0];
                this.grdHarnSel.Refresh();
                Module1.newModule.oldSel = false;
            }
        }

        private void grdHarnSel_Click(object sender, EventArgs e)
        {

        }

        public frmHarness()
    {
        InitializeComponent(); 
    }
    }
}

